python - 预接收 Hook 中的 git push 选项

标签 python git gitlab

我正在用 python 编写一个 git pre-receive 钩子(Hook),并希望在推送选项中接收从命令行传递的参数。

git push -push-option='my option'

如何访问我的预接收 Hook 内的推送选项?

最佳答案

参见 githook 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.

关于python - 预接收 Hook 中的 git push 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48463761/

相关文章:

git - 测试 git 的 merge 后钩子(Hook)脚本

GitLab:无法将代码推送到服务器?

docker - Gitlab Runner 卡在 docker 登录

multithreading - 通过 golang 进行 gitlab 抓取的问题

python - Matplotlib 不可见注释

python - xml.etree.ElementTree getElementByID()?

git - 查找当前版本和上一版本之间的差异

python - 读取后从文本文件中删除行

Python 无法解释的关键字 'sub'

git - 什么是 Git 快进?