GIT PHP钩子无法成功执行
PHPz
PHPz 2017-04-11 10:34:05
[PHP讨论组]

GIT使用的是git.oschina.net的,
本地之前git conle的都正常,
然后做了一个钩子,
可是一直更新不了,
一直就显示

Hook Ok! 本地版本库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);
PHPz
PHPz

学习是最好的投资!

全部回复(1)
怪我咯

1:先切换php运行的用户
2:使用php运行用户git clone 项目
3:用php代码git pull

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号