php git 钩子,GIT PHP钩子无法成功执行

GIT使用的是git.oschina.net的,

本地之前git conle的都正常,

然后做了一个钩子,

可是一直更新不了,

一直就显示

Hook Ok! 本地版本库1路径

权限什么都对的,

麻烦那位帮我看下,

还有可以帮我增加一个日志记录并保持到文件的功能吗,

方便查看下错误。

error_reporting(E_ALL);

// 钩子密码

$password = 'password';

// 本地版本库路径

$pathArr = [

'本地版本库1' => '本地版本库1路径',

'本地版本库2' => '本地版本库2路径',

'本地版本库3' => '本地版本库3路径',

'本地版本库4' => '本地版本库4路径',

];

// 更新的版本库标识

$rep = $_GET['rep'];

if (! is_string($rep) || $rep == '' || ! isset($pathArr[$rep])) {

@error_log('Hook Error! Rep not match!');

exit('Hook Error! Rep not match!');

}

// 密码校验

$req = file_get_contents("php://input");

$req = @json_decode($res, true);

if (! is_array($req) && isset($req['password']) || $req['password'] == $password) {

@error_log('Hook Error! Pasword not match!');

exit('Hook Error! Pasword not match!');

}

// 更新版本库

$path = $pathArr[$rep];

$res = shell_exec("cd $path && git checkout master && git pull origin master 2>&1");

@error_log('Hook Ok! '.$path.' '.$res);

exit('Hook Ok! '.$path.' '.$res);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值