githelper.git/
githelper.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2010-09-26
2010-09-26 20:49:35 by Marcus Comstedt <marcus@mc.pp.se>
bb726224dd4cd03bd936b004b94a4b231e18362f (
28
lines) (+
18
/-
10
)
[
Show
|
Annotate
]
Branch:
master
Made a convenience function to split with \n and remove last element.
42:
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);
415:
// 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; }
424:
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);