1

We are interested of making a script that simplify our building process.

For that, we need to list the Git features that were merged onto one or more develop branches, since our last build.

I made this quick example, sorry for lack of design.

Let's imagine we are currently onto the build2 merge commit.

We want to know (from script) which features were delivered and are then concerned by this build.

Those features are D7 and D6, as they were merged on their respectives develop branches.

The difficulty there is probably to ignore the previous commits (D4, D3 and such) that was already present in our previous build and the fact that there is two develop branches which merge successively.

I know we can get get merges commits that exists on one branch and not another.

Using something like:

git log --oneline --merges --abbrev-commit origin/develop/$BRANCH...origin/release/$BRANCH

But this gets more complicated when using multiple develop or projects branches. And will probably returns false positives.

(there may be conflicts resolution commits that will change behavior)

Is there a better idea to do something like that ?

Biffen
  • 6,249
  • 6
  • 28
  • 36
Retsim
  • 433
  • 1
  • 5
  • 19
  • It's a bit unclear how/when is `develop2` merged back into `release` branch, but assuming both dev branches are merged into `release` just before each build, `git log --oneline --no-merges build1..build2` should return commits D6 and D7 only. – Romain Valeri Jan 20 '21 at 15:38
  • Yes in the example both develop are merged into the release at the same time and directly. (develop2 is not merged into develop1, as this is all black this may be misleading sorry) – Retsim Jan 20 '21 at 15:45
  • In fact I can use the log --oneline --merges between the two builds, it gives me all the merges that happened between them. But depth of graph is not important ? That would suit our case perfectly, and really simple ! Tried and worked fine, I got D6 and D7 commits. Using --merges to get the merges (as there is the branch name I can then parse) – Retsim Jan 21 '21 at 09:24
  • 1
    OK I get why you were looking for merges. Problem solved? – Romain Valeri Jan 21 '21 at 09:46
  • @RomainValeri Yes, answer the question with this info so I can validate if you want, thanks ! – Retsim Jan 25 '21 at 08:54

1 Answers1

1

Since you added in comments that both dev branches are merged into release before each build, here's how you can list commits between builds :

git log --oneline --no-merges build1..build2

...which should return only commits D6 and D7.

(For the record, the A..B (two dots) range in git means "everything that is reachable from B but NOT reachable from A". The A...B construct (three dots) is a different thing, it's the symmetrical difference between A and B, so it's like asking A..B plus B..A)

Note : the --no-merges option was the typical way to get only "useful" commits, but your context (parsing merge messages) explains why you needed --merges instead.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61