Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom change-id in gerrit

Tags:

git

gerrit

Is it possible to have a 'custom' change-id in a gerrit commit message?

For example,

- My commit message

Change-Id: BM10945

Where BM10945 is the bluemine ticket the change is for.

I keep getting a (missing or invalid Change-Id line format in commit message footer) from gerrit, and can't commit.

like image 371
Jarrett Avatar asked Jul 29 '13 16:07

Jarrett


3 Answers

You can use the commentlink config to automatically parse ticket numbers in commit messages, and show them as links in the Gerrit web interface.

E.g. for your redmine ones:

[commentlink "redmine"]
  match = "(BM[0-9]+)"
  html = "<a href='http://www.redmine.org/issues/$1'>$1</a>"

Also, you can use the TrackingID to add a footer containing a link to a tracking database although note that if you're using the simplest setup which uses the embedded H2 database, the you have to run the ScanTrackingIds program manually when Gerrit is offline which doesn't make it feasible.

Finally, if you want some other form of linking tickets to redmine tickets, such as email updates containing a link or make gerrit actions (publish patchset, merge) update the ticket, use Gerrit hooks (slightly different than regular git hooks) and some scripting to connect them.

like image 104
Motti Strom Avatar answered Sep 21 '22 17:09

Motti Strom


In complement to Carl Norum's answer, you can indeed create your own ChangeId as long as :

  • It starts with an uppercase I;
  • It contains 32 hexadecimal characters;

One sample format could be :

I201611160832aa0000000000786176696572

It starts with the date and time (YYYYMMDDHHMM), followed by a separator, and then the name of the committer in hexa format (here i used ascii, but one could use another format), padded with 00.

like image 30
XGouchet Avatar answered Sep 19 '22 17:09

XGouchet


No, you can't. You need to use Gerrit's own Change-Id format. You can have one autogenerated for your commit by installing the commit-msg hook script included with Gerrit. More information is available at the Gerrit Change-Ids documentation.

like image 34
Carl Norum Avatar answered Sep 21 '22 17:09

Carl Norum