githelper.git
/
githelper.pike
version
»
Context lines:
10
20
40
80
file
none
3
githelper.git/githelper.pike:517:
check_gitattributes_files(); } } /* Checks run before accepting a push */ class PreReceiveHook { inherit CommitHookUtilsRepo;
+
static array(string) commits_to_check = ({});
+
int check_tag_push(string old_sha, string new_sha, string ref_name) { string oldtag = String.trim_all_whites(run_git_ex(1, "rev-parse", "--verify", "-q", ref_name)); if (sizeof(oldtag) && oldtag != new_sha) { write("Tag %s already exists with value %s, will not move it\n", ref_name, oldtag); return 1; }
githelper.git/githelper.pike:544:
// New branch, maybe check if the name is allowed... return 0; } else { string merge_base = String.trim_all_whites(run_git("merge-base", old_sha, new_sha)); if (merge_base != old_sha) { write("Push to %s is not fast-forward.\n", ref_name); return 1; }
-
foreach(
split_lf(run_git("rev-list", old_sha+".."+new_sha))
, string sha)
-
if(check_commit(sha))
-
return 1
;
+
commits_to_check +=
split_lf(run_git("rev-list", old_sha+".."+new_sha));
return 0; } } int check_push(string old_sha, string new_sha, string ref_name) { if (has_prefix(ref_name, "refs/tags/")) { return check_tag_push(old_sha, new_sha, ref_name); } else if (has_prefix(ref_name, "refs/heads/")) { return check_branch_push(old_sha, new_sha, ref_name);
githelper.git/githelper.pike:572:
int hook() { 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; }
+
foreach(Array.uniq(commits_to_check), string sha)
+
if(check_commit(sha))
+
return 1;
return 0; } } /* Do housekeeping after a commit */ class PostCommitHook { inherit CommitHookUtilsRepo;