2

We are working with git/gerrit and have hooks in place to add change-id for every commit. We have commit-msg hook placed in repo/.git/hooks/ folder. But not everyone is following this and since project is huge, its hard to track who is not doing individually. Hence, we have few commits in gerrit without change Id.

Now is there any way we can stop such commits to be pushed at all? Any server side hook or any other way where hooks are not applied by an individual locally but still we can stop him to push wrong commits?

user3256114
  • 119
  • 1
  • 13

2 Answers2

1

The documentation states:

Gerrit does not run any of the standard git hooks in the repositories it works with, but it does have its own hook mechanism included via the hooks plugin.

That hook plugin does include:

Require Change-Id in commit message

So if you can activate it on your Gerrit server, that should be enough to avoid any commit without a change id.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • See also https://stackoverflow.com/a/48359042/6309 or https://stackoverflow.com/a/44682008/6309 – VonC Nov 28 '18 at 05:44
0

You just need to enable the "Require Change-Id in commit message" option in the project configuration. This can be done in the specific project configuration or can be configured in a parent project, normally in the All-Projects project, and inherited to other projects.

See more details in the documentation here.