post-receive hook tell which repo you are in

时间:2015-09-01 22:41:01

标签: ruby git gitlab

I have a gitlab server. Gitlab has its own hooks symlinked to every git repo. I wish to be able to tell the difference in between repos when that script is called. I seen this but I don't think it provides any useful information in this case.

Perhaps it may be possible to detect which repo the hook belongs to by figuring out where the script was executed from? (The original script is in ruby) Or possibly to check /home/git/git-data/repositories/<all git users>/<all repos> for the right ref? Either way I do not know how to do that.

1 个答案:

答案 0 :(得分:0)

在你的钩子里,你可以尝试:

git rev-parse --git-dir

那应该给出一个裸仓的完整路径,其中钩子(这里是一个接收后的)被执行。
这就是我在“Is there a way to get the git root directory in one command?”中使用的内容。