Search code examples
gitscriptinggit-mergegit-commitgit-flow

Retrieve list of features from develop(s) concerned by a build on release branch


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 ?


Solution

  • 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.