Make it easy to learn how a given commit made it into master

My Git Blame Workflow

I often find myself using the following workflow:

  1. Find what appears to be a bug

  2. Decide to look for clues by finding the commit in which it was added

  3. Visit the file on GitLab and click "blame" (or type git blame ./path/to/some_file.js in the shell)

  4. I find that the bug was introduced in a particular commit (let's say it's 2f87703c)

  5. Try to figure out what MR contained 2f87703c for some extra context.
    I do this so often that I've put a handy script in my .gitconfig aliases to locate the point at which a commit gets merged into a given branch:

    find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
    show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
  6. I type git find-merge 2f87703c master to get the SHA of the merge commit in which a1b2c3d4 was added to master (it returns 46533a7d).

  7. I then look up 46533a7d and see that the commit message references MR !8095.

  8. I look at all of the commits found in this MR to get the context I need to conclude my research.

Proposed Feature

I've found this find-merge step so useful that I think it would warrant inclusion on GitLab itself. It would be amazing if I could just go to a commit page, and click a "get context" button to research where this commit ended up in master (i.e. which merge commit contains this commit).

Screen_Shot_2016-12-22_at_11.11.38_AM_copy

Or include it right in the metadata next to where we show the branches:

Screen_Shot_2016-12-22_at_11.20.14_AM_copy

Or even better yet, find the merge commit then cross reference that with any closed merge requests which reference this SHA and give a direct link to the merge request:

Screen_Shot_2016-12-22_at_11.22.08_AM_copy

The latter two concepts may require too much processing to be done on every commit page load, so perhaps a "get context" button would be more practical for performance reasons.

This would be a very handy tool for anyone who does a lot of digging into commit history for context, and AFAIK our competitors have nothing like this.

Assignee Loading
Time tracking Loading