0

We have a typical workflow where development is done on Git feature branches. Changes on master are pulled into the feature branch and when finished, the feature branch is merged into master (which mostly works without conflicts).

The feature branches are built continuously on Jenkins (one project per branch), especially in order to run tests that are difficult to do on development machines. A notification of the outcome of those builds (failure or success) must be sent to the involved developers. From a practical point of view the involved developers are those working on the feature branch. It is not necessary that all of those developers get a notification, it would be sufficient to send it to that person that did the last change on the branch (meaning: changing the value of the branches HEAD).

The question is: How to determine those developers programatically? I am aware of the fact that this might not be possible to 100%, the goal is to find a feasible but not perfect solution.

Something that must not happen is that commit authors that never worked on the branch get notifications. When master is merged into the branch and after the initial branch creation there are (a lot of) commit authors not related to the branch.

I will put the approach I have in mind as answer, but I am interested if there are better solutions.

Gustave
  • 2,787
  • 4
  • 27
  • 56

1 Answers1

0

I would take the set of all commits on the feature branch and remove all commits that appear on master. This is possible with git log ^master branch-name. Of the remaining commits I would take the author of the newest one. In case of a pull from master, the notification would be sent to the last one who commited to the branch before the pull.

There is still the problem that there might be no commits at all on the branch (in the sense of commits not reachable from master). This will be especially the case for the first build on a new branch.

Gustave
  • 2,787
  • 4
  • 27
  • 56