Gerrit change-merged Hook

北城余情 提交于 2019-12-04 12:38:12

Something like this:

#!/bin/sh

# See link below for actual command line format
# you may need to make the argument parsing more robust
CHANGE_ID=$2

git clone ${GIT_DIR} /tmp/repo-${CHANGE_ID}
echo "#version Change-Id: ${CHANGE_ID}" > /tmp/repo-${CHANGE_ID}/version.txt
GIT_DIR=/tmp/repo-${CHANGE_ID}/
cd /tmp/repo-${CHANGE_ID}/
git add /tmp/repo-${CHANGE_ID}/version.txt
git commit -m'Auto-updated version'
git push origin master
rm -rf /tmp/repo-${CHANGE_ID}/

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.

Better to do it the other way around -

Instead of doing an "un-verified" change to a commit, behind Gerrit's back,
put a git-tag on that commit.

For more details, see Git - Tagging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!