githelper.git
/
githelper.pike
version
»
Context lines:
10
20
40
80
file
none
3
githelper.git/githelper.pike:1:
#! /usr/bin/env pike #define DOLLAR "$" constant unexpanded_id = DOLLAR"Id"DOLLAR; mapping(string:program) hooks = ([ "pre-commit" : PreCommitHook, "pre-receive" : PreReceiveHook, "post-commit" : PostCommitHook,
+
"post-rewrite" : PostRewriteHook,
]); mapping(string:program) filters = ([ #if 0 "nice_ident" : NiceIdentFilter, #endif ]);
githelper.git/githelper.pike:614:
} string cm_test = check_commit_msg("HEAD"); if (cm_test) { write("NOTICE: Your commit message has an encoding problem:\n%s", cm_test); write("Please ament it before pushing.\n"); } return 0; } }
+
class PostRewriteHook
+
{
+
inherit CommitHookUtilsRepo;
+
+
int hook(string command)
+
{
+
if (command == "rebase") {
+
int errs = 0;
+
foreach(split_lf(Stdio.stdin->read()), string line) {
+
string old_sha, new_sha, extra;
+
if(sscanf(line, "%s %s%*[ ]%s", old_sha, new_sha, extra) != 4)
+
fail("Unparsable input line %O!\n", line);
+
errs += check_commit(new_sha);
+
}
+
if (errs)
+
write("NOTICE: %d of the commits contain errors. Please amend before pushing.\n", errs);
+
}
+
return 0;
+
}
+
}
+
/* Filters */ /* A sample filter, not really useful... */ class NiceIdentFilter { static string replace_id(string f, function(string:string) replace) { int p=0; while((p=search(f, DOLLAR"Id", p)) >= 0) { int p2 = search(f, DOLLAR, p+3), p3 = search(f, "\n", p+3);