【发布时间】:2015-08-10 17:02:03
【问题描述】:
我试图了解当多个提交被推送到一起时,git post-receive 钩子会发生什么。从我看到的文档和示例中,我希望它接受来自 STDIN 的引用列表,允许我对每个单独的提交采取行动,但它似乎不是这样工作的?这是我所拥有的:
我的 post-receive 钩子,显然这只是为了测试:
#!/usr/bin/perl
use Data::Dumper;
my @input = <STDIN>;
print STDERR Dumper(\@input);
我编辑了两个文件,分别提交:
nelson% git log origin/master..HEAD
commit 93f96201f2cfd3e83a9a609ec644dc873aefeb17
Author: cecukemon <cecukemon@...>
Date: Thu May 28 11:09:19 2015 +0200
commit 2
commit 8bbcc8370101d44c8a7302fb365f257e62a61e9d
Author: cecukemon <cecukemon@...>
Date: Thu May 28 11:09:09 2015 +0200
commit 1
将它们合二为一:
nelson% git push
Counting objects: 6, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 542 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: $VAR1 = [
remote: 'fa45b972bb59fbe92d7331cfad5d2933a53414ce 93f96201f2cfd3e83a9a609ec644dc873aefeb17 refs/heads/master
remote: '
remote: ];
To /home/cecukemon/hooktest
fa45b97..93f9620 master -> master
两次提交均已成功推送:
nelson% git log origin/master..HEAD
nelson%
并且 post-receive 挂钩已成功执行,但我只在参考列表中看到其中一个提交(推送输出中的 $VAR1)。
我是否从根本上误解了接收后挂钩的工作原理?
【问题讨论】:
标签: git githooks git-post-receive