Home > Software design >  How to get a list of merge commits to develop that are not merged to master ... and vice versa
How to get a list of merge commits to develop that are not merged to master ... and vice versa

Time:01-27

Our workflow is very manual at the moment.

Jira for tickets, Bitbucket for repos. Many repos. Way too many repos.

Using Sourcetree, showing the develop branch, parents only, compare against a spreadsheet we have maintained for years of all the different repos and so we can see (and make reports/charts) of what and when merges and releases happen. It works. It's cumbersome.

We VERY VERY VERY rarely push plain commits to master or develop. Normally it is always merge commits of feature branches to develop, or hotfix branches to master.

What we are wondering is .. for a given repo, can we create a simple list of the merge commits to develop that have not been merged to master.

We want to extract this information from several repos, and then merge and sort that list, so that we have the list of merges in the order that they were made across all the required repos.

Once I can get a list of develop merges not in master, and the reverse as hotfixes exist and the current workflow means a lot of manual switching to get that info.

We have a commit-msg hook that puts the Jira ticket number at the beginning of the commit message, so the pattern would be ^[A-Z] -\d . If that pattern doesn't fit, then the author's email address as we have ... occasionally ... done a quick manual patch whilst releasing.

So the output we're looking for would be something like:

IN-1234[TAB]<current directory>[TAB]<develop commit date>[TAB]<develop commit hash>[TAB][TAB]
IN-1232[TAB]<current directory>[TAB]<develop commit date>[TAB]<develop commit hash>[TAB][TAB]
IN-1236[TAB]<current directory>[TAB]<develop commit date>[TAB]<develop commit hash>[TAB][TAB]
[email protected][TAB]<current directory>[TAB][TAB][TAB]<master commit date>[TAB]<master commit hash>

sort of thing.

If the ordering can be based upon the largest value of the 2 <commit date>s then great, but the data in the above format would fit into our spreadsheet and that has all the formulas and sorting features.

I'm happy to do all the scripting ... I just don't know how to do the search/compare/report bit of git.

Info: We merge one branch at a time to develop and one merge commit from develop to master, to allow for easy revert from master if the deployed code ends up needing to be removed ... rare ... but happens ... we do the revert in master, merge commit to develop, create new branch and then revert the revert to recreate the reverted code into a branch ... all manual ... so much manual!!! Years of this manual! Please be gentle!!!!

CodePudding user response:

To get commits on develop not merged to master:

git log master..develop

To include only merge commits in the output (exclude regular commits):

git log --merges master..develop

Note that this will only work for "real" merges, any kind of rebase, cherry-pick, or squash-merge will not be detected as "merge".

Use --format or --pretty to only output the information that you need.

  • Related