githelper.git
/
githelper.pike
version
»
Context lines:
10
20
40
80
file
none
3
githelper.git/githelper.pike:35:
} array(string) split_z(string data) { array(string) a = data / "\0"; if (sizeof(a) && a[-1] == "") a = a[..sizeof(a)-2]; return a; }
+
array(string) split_lf(string data)
+
{
+
array(string) a = data / "\n";
+
if (sizeof(a) && a[-1] == "")
+
a = a[..sizeof(a)-2];
+
return a;
+
}
+
string run_git_ex(int max_exitcode, string ... args) { mapping res = Process.run(({"git"})+args); if (res->exitcode > max_exitcode) { werror(res->stderr); fail("git exited with code %d\n", res->exitcode); } return res->stdout; }
githelper.git/githelper.pike:408:
return check_blocker_attributes() || check_gitattributes_files(); } int check_push(string old_sha, string new_sha, string ref_name) { if(old_sha == "0"*40) { // New ref, maybe check if the name is allowed... return 0; } else {
-
foreach(run_git("rev-list", old_sha+".."+new_sha)
/"\n"
, string sha)
-
if(
sizeof(sha) &&
check_commit(sha))
+
foreach(
split_lf(
run_git("rev-list", old_sha+".."+new_sha)
)
, string sha)
+
if(check_commit(sha))
return 1; return 0; } } int hook() {
-
foreach(Stdio.stdin->read()
/ "\n"
, string line)
-
if(sizeof(line))
{
+
foreach(
split_lf(
Stdio.stdin->read()
)
, string line) {
array(string) args = line / " "; if(sizeof(args) != 3) fail("Unexpected input line to pre-receive hook: %s\n", line); if(check_push(@args)) return 1; } return 0; } }