Skip to content

Commit 00a6e2e

Browse files
committed
Omit abort on conflict skipping, if no cherry-pick is in progress
Checks whether any reverts or cherry-picks are in progress, when user answers Yes to the "Continue from the next commit (Yes/no)?" prompt when a the process runs into a merge conflict. If there is no active revery or cherry-pick in progress, expect that the conflict has been resolved by the user and continue to the next commit without abort. Previous, answering Yes, would invoke abort command, which would fail if the user had already resolved conflicts. The previous workflow expected that the user would answer no, and then run the git-draft command again after the conflict had been resolved. Now with this change, running the command again isn't necessary, and it's enough to keep git-draft open on the background. Closes #6
1 parent 2ad81ed commit 00a6e2e

3 files changed

Lines changed: 29 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.3.0
4+
5+
* Omit abort on conflict skipping, if no cherry-pick is in progress,
6+
expecting that the user has already resolved the conflict and continue from
7+
the next commit (closes #6).
8+
39
## 0.2.0
410

511
* Ability to revert commits with `--revert` option. Instead of cherry-picking

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ For available commands, see:
2727
$ make help
2828
```
2929

30-
Coding style
30+
Running linter and tests
3131
-----
3232

33-
To verify that your additions follows coding style, run:
33+
To verify that your additions follow coding style and to execute tests, run:
3434

3535
```shell
36-
$ make lint
36+
$ make test
3737
```
3838

3939
Configure git

src/git-draft

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ fatal () {
168168
}
169169

170170
pick () {
171-
local selection hash
171+
local selection hash git_directory
172+
173+
git_directory=$(git rev-parse --git-dir) \
174+
|| fatal "${red}${reset} Not inside a git directory."
172175

173176
hashes "$@"
174177

@@ -317,13 +320,17 @@ revert () {
317320

318321
err "${red}${reset} Reverting ${yellow}$hash${reset} failed"
319322

320-
read -r -p "Skip and continue from the next commit (Yes/no)? " abort
323+
read -r -p "Continue from the next commit (Yes/no)? " abort
321324

322325
case "$abort" in
323326
Y*|y*)
324-
run revert --abort \
325-
|| fatal "${red}${reset} Aborting revert failed"
326-
;;
327+
if [ -f "${git_directory}/REVERT_HEAD" ]; then
328+
run revert --abort \
329+
|| fatal "${red}${reset} Aborting revert failed"
330+
else
331+
log "${magenta}${reset} No revert in progress, continuing without abort"
332+
fi
333+
;;
327334
*)
328335
fatal "${red}${reset} Exiting and leaving revert in progress"
329336
;;
@@ -355,13 +362,17 @@ cherry-pick () {
355362

356363
err "${red}${reset} Cherry-picking ${yellow}$hash${reset} failed"
357364

358-
read -r -p "Skip and continue from the next commit (Yes/no)? " abort
365+
read -r -p "Continue from the next commit (Yes/no)? " abort
359366

360367
case "$abort" in
361368
Y*|y*)
362-
run cherry-pick --abort \
363-
|| fatal "${red}${reset} Aborting cherry-pick failed"
364-
;;
369+
if [ -f "${git_directory}/CHERRY_PICK_HEAD" ]; then
370+
run cherry-pick --abort \
371+
|| fatal "${red}${reset} Aborting cherry-pick failed"
372+
else
373+
log "${magenta}${reset} No cherry-pick in progress, continuing without abort"
374+
fi
375+
;;
365376
*)
366377
fatal "${red}${reset} Exiting and leaving cherry-pick in progress"
367378
;;

0 commit comments

Comments
 (0)