Unable to determine if branch was merged using squash

My team uses github and sourcetree to manage our workflow. We recently started checking out the merge function of github screens. We really like the way he keeps our work history in order and essentially has a single fixation on PR.

One of the unexpected drawbacks of using squash commits is that it is difficult to determine when a local branch can be removed. It seems that my whole team is managing their local branches, because they can visually see on the commit graph that it was merged, and every few days we will go through our local branches one by one, seeing if they were merged, and then delete it locally if there is one. Enabling squash merging removes this visualization and makes it difficult to determine if a branch has been merged.

We really would like to use the compilation function, but we need a reliable way to determine if a branch has been merged and safely deleted locally. Are there any good ways we have not thought of to achieve this?

+5
source share
1 answer

My whole team seems to be managing its local branches based on the ability to visually see in the commit graph that it has been merged,

This seems to be a real problem right here. If you are already using the GitHub pull-request workflow, the status of the transfer request should be the authoritative answer to this question. Is PR accepted? Good! Branch merged, continue your life.


One option that you might want to consider is to accept (and possibly enforce) a workflow in which you accept only one-time requests. Let people do whatever they want in their local repositories, but by sending a pull request, they distribute the corresponding commits together before sending (and make free use of the redirect workflow locally to update the transfer request if they need to make changes).

This has the advantage that the “visual validation” method will continue to work as you will no longer synthesize commits on GitHub.


Update

I put together a small tool that uses the GitHub API to determine if download requests associated with this commit have been closed. Dip the git-is-merged script in your $PATH somewhere, and then you can do this:

 $ git checkout my-feature-branch $ git is-merged All pull requests for 219e0f04a44053633abc947ce2b9d700156de978 are closed. 

Or:

 $ git is-merged my-feature-branch All pull requests for 219e0f04a44053633abc947ce2b9d700156de978 are closed. 

The script returns status text and exit codes for:

  • No traction requests
  • All download requests are closed.
  • Some transfer requests are closed.
  • All download requests are open.

For crushed commits, you can use any of the commit commands that were part of the original pull or commit sha request for a compressed commit.

As written, this tool will only work with public repositories, but it uses the PyGithub module, which supports authentication.

+4
source

Source: https://habr.com/ru/post/1258954/


All Articles