Skip to content

Commit

Permalink
Problem: failed merge request merging
Browse files Browse the repository at this point in the history
When a merge request is failed, the user is left
with the task of re-applying the patch and finishing
the merging/closure of the issue. This is not a great
user experience.

Solution: enable three-way merge to allow manual resolution of the
conflict and detect if the script is called from a merge branch and
pick it up from where it was left, assuming that the changes were done.
  • Loading branch information
yrashk committed Apr 25, 2018
1 parent 3122826 commit 806eb01
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cli/sit-mr-merge
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ comment=$3
tmpdir="$(mktemp -d)"
curdir=$(pwd)
editor=${EDITOR:-nano}
range=$(git merge-base --fork-point master $branch)..$branch
curbranch=$(git rev-parse --abbrev-ref HEAD)
sit=${SIT}

Expand All @@ -22,10 +21,16 @@ fi

repo=$(${sit} path)

git checkout -b merge-${item}-${mr} || exit 2

git am $(ls ${repo}/items/${item}/${mr}/git/*.patch) || exit 2
if [ "${curbranch}" != "merge-${item}-${mr}" ]; then
git checkout -b merge-${item}-${mr} || exit 2
git am -3 $(ls ${repo}/items/${item}/${mr}/git/*.patch) || exit 2
else
echo "Reusing current merge branch"
fi

# Find the branch we forked from
forkpoint=$(git merge-base --fork-point HEAD)
curbranch=$(git branch --contains ${forkpoint}~ --points-at ${forkpoint}~)

pushd $(pwd) >/dev/null
cd "${tmpdir}"
Expand Down

0 comments on commit 806eb01

Please sign in to comment.