设置预提交钩子服务器端 [英] Setting pre-commit-hook server side

查看:170
本文介绍了设置预提交钩子服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$

解决方案

是否可以在服务器repo中设置pre-commit-hooks,并在repo被克隆时将它们下载到客户端? / div>

git-scm


这些钩子都存储在Git目录的钩子子目录中。在大多数项目中,这是 .git / hooks


回想一下 .git / 是本地管理的。



所以,不,没有编程方式只使用git来强制一个存储库,用于在克隆时安装钩子。



也就是说,通常的做法是将钩子绑定到像钩子这样的文件夹中/ ,然后




  • 解释如何将它们安装到自述文件中,或者

  • 提供一个脚本,在克隆用户必须手动运行后安装它们。



如果你有想要验证的规则,如果有人使用了钩子,你可以用它来抽烟测试,你可以在远程安装 pre-receive 钩子。



例如,如果你有一个pre-commit钩子预先支持一个分支标识符来提交消息,你可以检查一个pre-recieve钩子(实际上在'server'上)提交消息以分行标识符开始。


Is it possible to set up pre-commit-hooks in the server repo and have them download to the clients when the repo is cloned?

解决方案

From git-scm:

The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that’s .git/hooks.

Recall that .git/ is managed locally.

So, no, there is no programmatic way using only git to force a repository to install hooks when it is cloned.

That said, a common practice is to bundle hooks into a folder like hooks/ within your repository, and then either

  • explain how to install them in the README, or
  • provide a script which will install them after cloning that the user has to run manually.

If you have rules you wish to validate, which you could use to smoke-test if someone has used a hook, you can install pre-receive hook in your remote.

For example, if you have a pre-commit hook that prepends a branch identifier to commit messages, you could check in a pre-recieve hook (actually on the 'server') that commit messages start with a branch identifier.

这篇关于设置预提交钩子服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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