我试图为git编写一个pre-receive hook,它将提取正在推送的代码的最新版本,并对其运行单元测试。我的代码如下所示,但是当它到达"git签出$newrev“时,我得到:
远程:致命:引用不是树: 188de39ca68e238bcd7ee9842a79397f39a5849e
在接收发生之前,我需要做些什么来检查正在被推送的代码?
#!/bin/bash
while read oldrev newrev refname
do
echo "Preparing to run unit tests for $newrev"
TEST_DIR=/op
我有一个git钩子,每当我按下时,它就会运行测试:
.git/hooks/pre-push
cd $GOPATH/src/lab.omitted.com/omitted/tools/tribute/
./run-newman-non-dkr.sh
我想在那里有一个旗子,这样我就可以不用运行测试就可以推杆了:
if [[ $* == *--skiptest* ]]
then
echo Skipping Newman Test
else
echo --- Running Newman Test
cd $GOPATH/src/lab.omitted.com/omitted/t
我运行的是 git服务器。
我的大多数用户都在运行git的3个版本中的1个。
git 1.7.1 (centos用户)
git 1.7.9 (其他所有人)
git 1.8.4 (mac用户)
一些用户意外地以root用户的身份提交和推送代码。我需要阻止来自这些用户的提交。
我的pre-commit钩子如下所示:
#!/bin/bash
if [[ $GIT_AUTHOR_NAME == 'root' ]]
then
echo "If you commit as root, you're gonna have a bad time";
e