git的:在空参数后收到钩 [英] git: empty arguments in post-receive hook
问题描述
我在写后收到关于后收到的电子邮件
从脚本的contrib
DIR钩筑底,但它似乎 OLDREV
和 NEWREV
参数是空的。
I'm writing post-receive hook basing on the post-receive-email
script from the contrib
dir, but it seems that the oldrev
and newrev
arguments are empty.
脚本如下:
#!/bin/bash
oldrev=$(git rev-parse $1)
newrev=$(git rev-parse $2)
脚本推送运行,但所有的 $ 1
, $ 2
, $ OLDREV
和 $ NEWREV
是空的。我应该配置的东西让它运行?
The script runs on push, but all $1
, $2
, $oldrev
and $newrev
are empty. Should I configure something to get it running?
(存储库是由 gitolite
创建如果这非常重要)
(The repository was created by gitolite
if it does matter)
推荐答案
的后接受
挂钩不带任何参数。答曰手动(强调):
The post-receive
hook doesn't take any arguments. Quoth the manual (emphasis added):
这钩子被混帐接收包的远程仓库,当一个混帐推是在本地存储库进行恰好调用。它执行在远程库中的所有裁判都被更新一次后。
This hook is invoked by git-receive-pack on the remote repository, which happens when a git push is done on a local repository. It executes on the remote repository once after all the refs have been updated.
这钩子接收操作执行一次。 它不带任何参数,但得到相同的信息 pre-收到
挂钩是它的标准输入。
This hook executes once for the receive operation. It takes no arguments, but gets the same information as the pre-receive
hook does on its standard input.
这个钩子不会影响结果的git - 接收包
,因为它真正的工作完成后调用。
This hook does not affect the outcome of git-receive-pack
, as it is called after the real work is done.
这取代了更新后
挂钩的,因为它得到,除了他们的名字全部裁判的新旧值。
This supersedes the post-update
hook in that it gets both old and new values of all the refs in addition to their names.
标准输出和标准错误输出将被转发到混帐发送包
在另一端,这样可以为用户简单地回应消息。
Both standard output and standard error output are forwarded to git send-pack
on the other end, so you can simply echo messages for the user.
默认后接受
挂钩是空的,但后收到的电子邮件
提供了一个示例脚本在git的分布的contrib /钩
目录中,它实现发送提交邮件。
The default post-receive
hook is empty, but there is a sample script post-receive-email
provided in the contrib/hooks
directory in git distribution, which implements sending commit emails.
这篇关于git的:在空参数后收到钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!