Project

General

Profile

[SOLVED] 4.1.1: how to make Git commits show up inside an issue

Added by Konstantin Kharlamov over 1 year ago

Given a Redmine project myhost.com/projects/test that have a Git repository integrated at myhost.com/projects/test/settings/repositories (the repo is browseable, i.e. everything works).

Now, I want commits created in the repository that refer to an issue, to appear on the page of the issue. Currently nothing commits-related appears on the issue page.

Version used is 4.1.1.

The question is basically the same as this one https://www.redmine.org/boards/2/topics/22654 except that the answer the author posted doesn't work for me (the repository settings do not have anything keywords-related), so decided to create a new topic.

Here's how repository settings page looks like:


Replies (4)

RE: 4.1.1: how to make Git commit history show up at Redmine issue tracker - Added by Konstantin Kharlamov over 1 year ago

Okay, so, a little bit of a progress: I found the keywords-related setting, its location is completely project-agnostic: Administration → Settings → Repositories.

The bad news though is that changing the setting does not make commits appear in the issue page. It seems to simply improve navigation: if you open a commit containing a keyword in Redmine, the keyword + number will be a link referring the issue.

So the question still stands.

RE: 4.1.1: how to make Git commits show up inside an issue - Added by Konstantin Kharlamov over 1 year ago

Okay, another finding: if (inside Redmine) you open a repository, and then a commit that refers to an issue like #7777, you'll see it says "Related issues". That means Redmine has successfully linked the commit to an issue, for example:

However, the issue linked still doesn't show the commit. But I also found the panel that supposed to show the commit is called "associated revisions", hopefully I'll find something by this keyword…

RE: 4.1.1: how to make Git commits show up inside an issue - Added by Konstantin Kharlamov over 1 year ago

Update: the panel "associated revisions" is randomly appeared, I didn't change anything. But many commits are missing.

From what I gather, the 4.1.1 Redmine has multiple bugs in commits association, as follows:

1. Setting "keywords" (see comments above) is not required for a commit to refer an issue and Redmine to understand it. That is, if inside a commit you do a "Fixes #777", the #777 will become a link to the issue 777. But! Redmine will not add the issue to the "Related issues" list of the commit (and hence to the "associated revisions" table).
2. Setting "keywords" to `#` (which is rational, that's usually how Gitlab and Github users refer to their issues) seems to have to influence whatsoever.
3. Setting keywords to e.g. `RM` kinda works… But is actually tricky. The issue will only be "linked" if the syntax is used as follows: `RM #777`. Exactly this syntax will work. Anything else: `RM 777`, `RM777`, `RM#777`, `RM-777`, will not.


So, the solution is basically:

1. Set up keywords inside global settings (it is not a per-project setting, but a global one)
2. Use inside commits the exact syntax mentioned above: if you set a keyword `RM`, then somewhere inside a commit (not necessarily at the beginning) should be a string "RM #777". For example: `Fixes: RM #777`.

RE: [SOLVED] 4.1.1: how to make Git commits show up inside an issue - Added by Konstantin Kharlamov over 1 year ago

OH MY GODS. Folks, I re-resolve it, there is some undocumented cool hack that makes it work NORMALLY. Some unknown dude has found it while setting up our old redmine instance, and by pure accident we just stumbled upon it and re-applied to the newer Redmine instance.

So, the better solution is:

1. Inside global "repository" settings (again, see above), inside the line "referencing keywords" set just `*`. That is, an asterisk and nothing else.
2. Inside commits use the usual Gitlab/Github-like syntax to refer to issues, so e.g. to refer a `777` the `#777` will work and the 777 will appear on the commit's page as a linked issue.

    (1-4/4)