Made the finishing of release/hotfix branches fail-safe. When a
release/hotfix branch fails finishing, the user may just try so again.
This commit is contained in:
parent
1a2868b8b4
commit
5fa4758e54
3 changed files with 70 additions and 29 deletions
|
@ -170,22 +170,41 @@ cmd_finish() {
|
|||
gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
|
||||
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
|
||||
|
||||
# merge into master
|
||||
# try to merge into master
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the merge into master was successful, we skip it now
|
||||
if ! gitflow_is_branch_merged_into $BRANCH $MASTER_BRANCH; then
|
||||
git checkout $MASTER_BRANCH || \
|
||||
die "Could not check out $MASTER_BRANCH."
|
||||
git merge --no-ff $BRANCH # TODO: This can fail!
|
||||
git merge --no-ff $BRANCH || \
|
||||
die "There were merge conflicts."
|
||||
# TODO: What do we do now?
|
||||
fi
|
||||
|
||||
# try to tag the release
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the tag was set successful, we skip it now
|
||||
typeset tagname=$VERSION_PREFIX$VERSION
|
||||
if ! gitflow_tag_exists $tagname; then
|
||||
typeset opts="-a"
|
||||
flag sign && opts="$opts -s"
|
||||
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
|
||||
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
|
||||
git tag $opts "$VERSION_PREFIX$VERSION" || \
|
||||
die "Tagging failed. Please run finish again to retry."
|
||||
fi
|
||||
|
||||
# merge into develop
|
||||
# try to merge into develop
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the merge into develop was successful, we skip it now
|
||||
if ! gitflow_is_branch_merged_into $BRANCH $DEVELOP_BRANCH; then
|
||||
git checkout $DEVELOP_BRANCH || \
|
||||
die "Could not check out $DEVELOP_BRANCH."
|
||||
git merge --no-ff $BRANCH # TODO: This can fail!
|
||||
|
||||
git merge --no-ff $BRANCH || \
|
||||
die "There were merge conflicts."
|
||||
# TODO: What do we do now?
|
||||
fi
|
||||
|
||||
# delete branch
|
||||
git branch -d $BRANCH
|
||||
|
|
|
@ -176,22 +176,40 @@ cmd_finish() {
|
|||
gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
|
||||
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
|
||||
|
||||
# merge into master
|
||||
# try to merge into master
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the merge into master was successful, we skip it now
|
||||
if ! gitflow_is_branch_merged_into $BRANCH $MASTER_BRANCH; then
|
||||
git checkout $MASTER_BRANCH || \
|
||||
die "Could not check out $MASTER_BRANCH."
|
||||
git merge --no-ff $BRANCH # TODO: This can fail!
|
||||
git merge --no-ff $BRANCH || \
|
||||
die "There were merge conflicts."
|
||||
# TODO: What do we do now?
|
||||
fi
|
||||
|
||||
# try to tag the release
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the tag was set successful, we skip it now
|
||||
typeset tagname=$VERSION_PREFIX$VERSION
|
||||
if ! gitflow_tag_exists $tagname; then
|
||||
typeset opts="-a"
|
||||
flag sign && opts="$opts -s"
|
||||
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
|
||||
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
|
||||
git tag $opts "$VERSION_PREFIX$VERSION" || \
|
||||
git tag $opts "$tagname" || \
|
||||
die "Tagging failed. Please run finish again to retry."
|
||||
fi
|
||||
|
||||
# merge into develop
|
||||
# try to merge into develop
|
||||
# in case a previous attempt to finish this release branch has failed,
|
||||
# but the merge into develop was successful, we skip it now
|
||||
if ! gitflow_is_branch_merged_into $BRANCH $DEVELOP_BRANCH; then
|
||||
git checkout $DEVELOP_BRANCH || \
|
||||
die "Could not check out $DEVELOP_BRANCH."
|
||||
git merge --no-ff $BRANCH # TODO: This can fail!
|
||||
git merge --no-ff $BRANCH || \
|
||||
die "There were merge conflicts."
|
||||
# TODO: What do we do now?
|
||||
fi
|
||||
|
||||
# delete branch
|
||||
git branch -d $BRANCH
|
||||
|
@ -203,7 +221,7 @@ cmd_finish() {
|
|||
echo "Summary of actions:"
|
||||
echo "- Latest objects have been fetched from '$ORIGIN'"
|
||||
echo "- Release branch has been merged into '$MASTER_BRANCH'"
|
||||
echo "- The release was tagged '$VERSION_PREFIX$VERSION'"
|
||||
echo "- The release was tagged '$tagname'"
|
||||
echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
|
||||
echo "- Release branch '$BRANCH' has been deleted"
|
||||
echo
|
||||
|
|
|
@ -148,6 +148,10 @@ gitflow_require_tag_absent() {
|
|||
fi
|
||||
}
|
||||
|
||||
gitflow_tag_exists() {
|
||||
has $1 $ALL_TAGS
|
||||
}
|
||||
|
||||
#
|
||||
# gitflow_test_branches_equal()
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue