Skip to content

Commit

Permalink
Omit abort on conflict skipping, if no cherry-pick is in progress
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gocom committed Jan 2, 2024
1 parent 2ad81ed commit 00a6e2e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.3.0

* Omit abort on conflict skipping, if no cherry-pick is in progress,
expecting that the user has already resolved the conflict and continue from
the next commit (closes #6).

## 0.2.0

* Ability to revert commits with `--revert` option. Instead of cherry-picking
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ For available commands, see:
$ make help
```

Coding style
Running linter and tests
-----

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

```shell
$ make lint
$ make test
```

Configure git
Expand Down
29 changes: 20 additions & 9 deletions src/git-draft
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ fatal () {
}

pick () {
local selection hash
local selection hash git_directory

git_directory=$(git rev-parse --git-dir) \
|| fatal "${red}${reset} Not inside a git directory."

hashes "$@"

Expand Down Expand Up @@ -317,13 +320,17 @@ revert () {

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

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

case "$abort" in
Y*|y*)
run revert --abort \
|| fatal "${red}${reset} Aborting revert failed"
;;
if [ -f "${git_directory}/REVERT_HEAD" ]; then
run revert --abort \
|| fatal "${red}${reset} Aborting revert failed"
else
log "${magenta}${reset} No revert in progress, continuing without abort"
fi
;;
*)
fatal "${red}${reset} Exiting and leaving revert in progress"
;;
Expand Down Expand Up @@ -355,13 +362,17 @@ cherry-pick () {

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

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

case "$abort" in
Y*|y*)
run cherry-pick --abort \
|| fatal "${red}${reset} Aborting cherry-pick failed"
;;
if [ -f "${git_directory}/CHERRY_PICK_HEAD" ]; then
run cherry-pick --abort \
|| fatal "${red}${reset} Aborting cherry-pick failed"
else
log "${magenta}${reset} No cherry-pick in progress, continuing without abort"
fi
;;
*)
fatal "${red}${reset} Exiting and leaving cherry-pick in progress"
;;
Expand Down

0 comments on commit 00a6e2e

Please sign in to comment.