Jarrett
Jarrett

Reputation: 1778

Custom change-id in 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.

Upvotes: 5

Views: 3215

Answers (3)

XGouchet
XGouchet

Reputation: 10203

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.

Upvotes: 2

Motti Strom
Motti Strom

Reputation: 2735

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.

Upvotes: 5

Carl Norum
Carl Norum

Reputation: 225032

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.

Upvotes: 4

Related Questions