From 219ec627b015cfa23e990e862da960ec8422b35c Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Wed, 2 Aug 2017 15:50:04 +0100 Subject: [PATCH 1/2] Perform git push before deleting branch This addresses an issue when using a feature branch that is associated with a pull request on GitHub when the develop branch is merge protected. In the current implementation of `git flow feature finish`, the remote feature branch is deleted before the merged develop branch has been pushed. This causes the pull request to be closed before the changes have been merged, so the approval no longer applies. To a certain extent this seems to be a bug with GitHub, but I don't see a drawback to pushing before deleting the remote branch. --- git-flow-feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-flow-feature b/git-flow-feature index 275f54bd..9aec8d74 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -435,6 +435,10 @@ helper_finish_cleanup() { require_branch "$BRANCH" require_clean_working_tree + if flag push; then + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + fi + remotebranchdeleted=$FLAGS_FALSE localbranchdeleted=$FLAGS_FALSE @@ -469,10 +473,6 @@ helper_finish_cleanup() { fi fi - if flag push; then - git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." - fi - echo echo "Summary of actions:" echo "- The feature branch '$BRANCH' was merged into '$BASE_BRANCH'" From 94ff231db8cc9765024193066f1c671a95d08055 Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Thu, 23 Aug 2018 20:28:00 +0100 Subject: [PATCH 2/2] Apply git push fix to other commands --- git-flow-bugfix | 8 ++++---- git-flow-feature | 6 +++--- git-flow-hotfix | 20 ++++++++++---------- git-flow-release | 24 ++++++++++++------------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/git-flow-bugfix b/git-flow-bugfix index 720e86dc..0d0fe7f7 100644 --- a/git-flow-bugfix +++ b/git-flow-bugfix @@ -438,6 +438,10 @@ helper_finish_cleanup() { remotebranchdeleted=$FLAGS_FALSE localbranchdeleted=$FLAGS_FALSE + if flag push; then + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + fi + if noflag keep; then # Always delete remote first @@ -469,10 +473,6 @@ helper_finish_cleanup() { fi fi - if flag push; then - git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." - fi - echo echo "Summary of actions:" echo "- The bugfix branch '$BRANCH' was merged into '$BASE_BRANCH'" diff --git a/git-flow-feature b/git-flow-feature index 9aec8d74..7b4729ab 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -435,13 +435,13 @@ helper_finish_cleanup() { require_branch "$BRANCH" require_clean_working_tree + remotebranchdeleted=$FLAGS_FALSE + localbranchdeleted=$FLAGS_FALSE + if flag push; then git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." fi - remotebranchdeleted=$FLAGS_FALSE - localbranchdeleted=$FLAGS_FALSE - if noflag keep; then # Always delete remote first diff --git a/git-flow-hotfix b/git-flow-hotfix index f97ed44a..855b52ff 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -582,6 +582,16 @@ T,tagname! Use given tag name run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" + if flag push; then + if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then + git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." + fi + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + if noflag notag; then + git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." + fi + fi + # Delete branch if noflag keep; then @@ -611,16 +621,6 @@ T,tagname! Use given tag name fi - if flag push; then - if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." - fi - git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." - if noflag notag; then - git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." - fi - fi - echo echo "Summary of actions:" if flag fetch; then diff --git a/git-flow-release b/git-flow-release index e9c542da..3105a085 100644 --- a/git-flow-release +++ b/git-flow-release @@ -174,6 +174,18 @@ _finish_from_develop() { run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" + if flag push; then + if flag pushdevelop; then + git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." + fi + if flag pushproduction; then + git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." + fi + if noflag notag && flag pushtag; then + git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." + fi + fi + # Delete branch if noflag keep; then @@ -207,18 +219,6 @@ _finish_from_develop() { fi fi - if flag push; then - if flag pushdevelop; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." - fi - if flag pushproduction; then - git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." - fi - if noflag notag && flag pushtag; then - git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." - fi - fi - echo echo "Summary of actions:" if flag fetch; then