Adding Git Commit Message to Commit Reference Link in GitLab Issue Note

1.4k Views Asked by At

We recently migrated from using Subversion and Trac to Git and GitLab. We successfully migrated all of our old data.

I'm still trying to learn GitLab and generally like it better than Trac, but one thing I don't like as much is that when you reference a GitLab Issue in the git commit, it adds a reference and link to that commit under the issue, but you have to browse to the commit itself to see the associated Git commit message.

In Trac, we had it configured such that the Subversion commit messages were all displayed in the Trac ticket with the commit link, so it was easier to view all the relevant information for that ticket in one place.

Is there a way to configure GitLab to display the Git commit message with the Git commit link that shows up under Issues? The message does show up in the commit list, but not on a referenced Issue.

I thought about trying to use a server hook to generate a note with the Git commit message when a commit is made, but just wondering if there is an easier/better way to accomplish this?

1

There are 1 best solutions below

1
On

There is no built-in way to show the commit message of a crosslinked commit in the issue log. After all, commits are handled the same way as any other mentions: in the issue's history/mention log.

While the example in GitLab's documentation unfortunately misses the opportunity to show an example of a mention in the commit, here's an issue from GitLab itself with a mention. This commit also shows how mentions often get used within commits—with keywords:

Merge branch '65375-broken-master-gitlab-svg-path-test-failing' into 'master'

Update failing jest snapshot

Closes #13186

See merge request gitlab-org/gitlab-ee!14933

These kind of commits close the specific issue and don't require any further user action. Adding that kind of noise to the discussion/comment section of an issue is, in my opinion, only cluttering the discussion between actual humans*. However, the commit still shows up in the log and is clickable and hoverable.

To get back to your question:

Is there a way to configure GitLab to display the Git commit message with the Git commit link that shows up under Issues?

If you hover over the linked commit, then you'll get the commit's subject. There's nothing more that can be achieved within GitLab itself.

I thought about trying to use a server hook to generate a note with the Git commit message when a commit is made, but just wondering if there is an easier/better way to accomplish this?

If you follow the usual commit/merge message based issue closing and use [Closes?|Fix(es)?] #issue in your commit message, you may end up with more noise in the comments than you would like too.

* well, except for some bots