reenhanced/gitreflow

github PR ends up "closed" instead of "merged"

dragonsinth opened this issue · 8 comments

The way 'deliver' currently works, the original PR ends up marked Closed instead of Merged.

There is a flow that can fix this.

  1. Perform the merge-squash against master.
  2. Force-push the original branch to update the PR.
  3. Attempt to push master (if it fails, loop back to step 1)
  4. Delete the original branch.

I'm not sure if a small sleep is required before step 4; at some time in the past github had a race condition where the PR might get marked closed or merged if you delete the upstream immediately after pushing master, but they might have fixed this now.

I am normally against the idea of force pushing, but the idea of hiding force pushing inside of a tool like this actually makes a ton of sense. This seems like a good idea to me

This is the second time this has come up (see #111). I think it would make sense to squash commits in the feature branch itself as well. As long as we're pulling in an update before force-pushing I don't see any real drawback.

Alternate solution is interactive rebase, which is very similar to a squash merge.

Personally I like an interactive rebase better, but I'm concerned it might be too advanced of a tool? Maybe we'll make it an option and default to merge --squash? @nhance thoughts here?

Agreed, interactive rebase is beyond the scope of reflow. It's a great idea and I love using it, but I think it places too much knowledge demand on those who might be new to reflow and not used to using it.

It doesn't really matter how you end up getting there; if you want to end up "merged" you have to force-push the original branch after you setup the new master; you also have to change the final commit message from "Closes #4" to something like "Merges #4" that doesn't auto-trigger github. Here's what I've patched for myself locally:

--- git_reflow-0.7.2/lib/git_reflow.rb.was
+++ git_reflow-0.7.2/lib/git_reflow.rb
@@ -145,6 +145,8 @@

             if deploy_and_cleanup
               run_command_with_label "git push origin #{base_branch}"
+              run_command_with_label "git push -f origin #{base_branch}:#{feature_branch}"
+              sleep 5
               run_command_with_label "git push origin :#{feature_branch}"
               run_command_with_label "git branch -D #{feature_branch}"
               puts "Nice job buddy."
--- git_reflow-0.7.2/lib/git_reflow/git_helpers.rb.was
+++ git_reflow-0.7.2/lib/git_reflow/git_helpers.rb
@@ -48,7 +48,7 @@
       message = "#{options[:message]}"

       if "#{options[:pull_request_number]}".length > 0
-        message << "\nCloses ##{options[:pull_request_number]}\n"
+        message << "\nMerges ##{options[:pull_request_number]}\n"
       end

       if lgtm_authors = Array(options[:lgtm_authors]) and lgtm_authors.any?

Fixed in v0.8.0 with 3b44510.