Can I send out of band data along with a commit?

自作多情 提交于 2019-12-07 05:43:41

问题


I wish to integrate a remote git repository with an RTC server, by using their RESTful interface to attach a link to gitweb for a commit associated with a particular task.

Ideally this will be done with a post-receive hook on the git server, but the processing user that git runs as is not allowed a user account to authenticate to RTC.

The best solution I can think of is to somehow pass an authentication token (Acquired from RTC in the form of cookies.txt) along with the git push (But not have it part of the commit).

The alternative would be a post-push hook on each client repository but that has its own problems (Including that there is no such hook).


回答1:


With git version 2.10 and higher, you can use git --push-option <string> to pass the given string value to the server, which passes them to the pre-receive as well as the post-receive hook. git push documentation.

The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,…​ If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.git hook documentation



来源:https://stackoverflow.com/questions/17787125/can-i-send-out-of-band-data-along-with-a-commit

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