我可以发送带外数据和提交吗? [英] Can I send out of band data along with a commit?

查看:174
本文介绍了我可以发送带外数据和提交吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将远程git存储库与RTC服务器集成在一起,通过使用它们的RESTful接口将链接附加到gitweb以提交与特定任务相关的提交。



理想情况下,这将通过git服务器上的post-receive钩子完成,但git运行的处理用户不允许用户帐户向RTC进行身份验证。



我能想到的最好的解决方案是以某种方式传递一个身份验证令牌(以cookies.txt的形式从RTC获取)以及git push(但不是提交的一部分)。



另一种方法是在每个客户端存储库上推后挂钩,但它有自己的问题(包括没有这样的挂钩)。

git --push-option < / code>来传递给定的字符串值传递给服务器,将它们传递给预接收和接收后挂钩。 git push文档

在git push --push-option = ...的命令行中给出的推送选项的数量可以从环境变量GIT_PUSH_OPTION_COUNT,而选项本身可在GIT_PUSH_OPTION_0,GIT_PUSH_OPTION_1,...中找到。如果协商为不使用推送选项阶段,则不会设置环境变量。如果客户端选择使用推送选项,但不传输任何数据,则count变量将被设置为零,GIT_PUSH_OPTION_COUNT = 0。 git hook文档


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).

解决方案

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

这篇关于我可以发送带外数据和提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆