I use git as my version control system and have set up a Gerrit site to do the code review. I would like to create a hook to do the following:
- When the admin clicks the Submit button, a file (called version.txt)
should be modified. - Script should open the file.
-
Find the following text (where the ID may change)
#version Change-Id: Ie1411d50f6beb885bc3d3b7d8c587635e1446c18 -
Replace the Change-Id with the Change-Id of the new patch.
-
So, if the patch being merged has the
Change-Id: I1c25f7b967084008b69a6a8aefa6e3bb32967b82then the version.txt file
should contain the following string after the script is run:#version Change-Id: I1c25f7b967084008b69a6a8aefa6e3bb32967b82 - Then the hook should create a new commit (since now there has been a change in one of the files) and push this last commit to master.
I feel this would be possible using a change-merged hook. Am I right?
Thanks in advance.
Something like this:
http://gerrit-documentation.googlecode.com/svn/Documentation/2.2.2/config-hooks.html#_change_merged
On principle, I’m not a fan of this approach, and I think it should be better done on the way out (e.g., a “install.sh” script, which can use git commands to extract the revision hash, and generate a version.txt file from there). But something like this should put you in the right direction. This is untested, but it should work.