0
Gitlab 配置自定义Git Hooks,检查PHP语法错误
首先查考Gitlab官方的Hook配置
https://docs.gitlab.com/ee/administration/custom_hooks.html
配置<project>.git/custom_hooks/pre-receive
pre-receive的内容如下
#!/usr/bin/php
<?php
echo "\nRunning php linter...\n";
$params = explode(' ', file_get_contents('php://stdin'));
$ref = trim($params[1]);
$diff = array();
$return = 0;
exec("git diff --name-only $params[0] $params[1] 2> /dev/null", $diff, $return);
if ($return > 0) {
echo "Could not run git diff\n\n";
// exit(1);
}
$filename_pattern = '/\.php$/';
foreach ($diff as $file) {
if (!preg_match($filename_pattern, $file)) {
continue;
}
$tree = array();
$return = 0;
exec("git ls-tree $ref $file 2> /dev/null", $tree, $return);
if ($return > 0 || empty($tree)) {
echo "Could not run git ls-tree\n\n";
exit(1);
}
$tree = preg_split('/\s/', $tree[0]);
$fileContents = array();
exec("git cat-file $tree[1] $tree[2] 2> /dev/null", $fileContents, $return);
if ($return > 0) {
echo "Could not run git cat-file\n\n";
exit(1);
}
$fileContents = implode("\n", $fileContents);
$pipes = array();
$proc = proc_open('php -l',
array(0 => array('pipe', 'r'),
1 => array('pipe', 'w')),
$pipes);
if (!is_resource($proc)) {
echo "Could not creater php linter process\n\n";
exit(1);
}
fwrite($pipes[0], $fileContents);
fclose($pipes[0]);
fclose($pipes[1]);
$resultCode = proc_close($proc);
if ($resultCode != 0) {
echo "Error parsing file '$file'\n\n";
exit($resultCode);
}
}
echo "No errors detected\n\n";
exit(0);
Recommend
Recent search keywords
- kubernetes
- znsfs
- ZNS
- Scalar size does not match
- 超星学习通
- httpsonlineschoolal5com99214
- skillz
- JCMM
- 垃圾场
- monitoro.co
- monitoro
- insta
- -1 OR 3 422-422-1=0 0 0 1
- font_heading
- pretzelai
- Hackintosh
- A52S
- UPDATE ROM AC8227L - Android JCAC10003-OC2-V1.0.04R7-211119_1742
- -1 OR 3+422-422-1=0+0+0+1
- The Path to Reliability: How a QA Engineer Should Act in Non-Standard Situations
- -1 or 3 446-446-1=0 0 0 1 --
- WRP Android Video Player Pro" AND 7796=9605 AND "BfKb"="BfKb
- wrp android video player pro and 8553=8553-- woed
- AJG LONDON LTD
- All blooks in blocker
- fatbobman
- 5200L
- supermarket HTB
- netherlands
- https://m.youtube.com/watch?v=XylKubQFAkw#
- python数据处理
- moto
- MTK 8227L Android download
- w89941
- gold quest blooket
- gold quest
- Phoneinfoga
- Instrukcja
- nvst.ly
- nvstly
- trade hub
- madagascar
- smartos
- omnios
- 快
- proxy list.txt
- All blooket
- watch hentai app
- hentai stream app apk android
- hentai stream
- ssl pterodactyl
- BACKGROUND REMOVER
- code.daypilot.org
- drops
- YT9217B
- Loil
- 教你做任务之
- antranigv.am
- 转盘
- fbi
- 下列何者可能是黃禹錫造假研究成果的原因
- gaminator
- 程序员
- -1 OR 3+789-789-1=0+0+0+1 --
- @@flq3T
- glizzy
- wrp android video player pro) and 5868=4380-- htou
- fishy frenzy
- -1 or 2+47-47-1=0+0+0+1
- GitHub - glixzzy/blooket-hack: Multiple hacks that breaks the game
- 1050
- fx
- golden
- gloadal
- all the answers
- best kodi live tv
- spreadsho[
- gift
- -1" OR 3+854-854-1=0+0+0+1 --
- -1 OR 2+930-930-1=0+0+0+1
- truenas
- Automotive Lubricants Market
- keywords+AND+7652=7652
- 5767
- 盗刷信用卡商店
- virtual))) OR NOT 1220=3959#
- kahoot hack
- -1 or 3+446-446-1=0+0+0+1 --
- cabinet+maker+in+australia
- blooket+market+infininty+conis
- virtual or not 9584=4739
- cabinet maker in australia
- -1 or 2+786-786-1=0+0+0+1 --
- ketfgb0j
- download230413-2+32+13.rar
- 230413-2+32+13.rar
- chapter 20 samsung pt 2
- chapter 20 samsung
- greek iptv and 5423=5004-- xcpg
- https://www.ongraph.com/hire-nodejs-developers/
一般我都是本地配置