githelper.git/
githelper.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2010-10-10
2010-10-10 19:38:22 by Martin Stjernholm <mast@lysator.liu.se>
2c951471506355db37d080397c68c080a35dfad8 (
42
lines) (+
26
/-
16
)
[
Show
|
Annotate
]
Branch:
master
Report all errors instead of stopping at the first one.
365:
int check_blocker_attributes() {
+
int err = 0;
foreach(files_to_commit, string filename) { mapping(string:string|int) a = attrs->checkattr(filename); if(a->foreign_ident == GitAttributes.ATTR_TRUE) { if (!entry_is_new(filename)) { write("File %s has the foreign_ident attribute. Please remove it before commit.\n", filename);
-
return
1;
+
err
=
1;
+
continue;
} } if(stringp(a->block_commit) || a->block_commit == GitAttributes.ATTR_TRUE) {
378:
write("File %s is blocked from committing: %s\n", filename, replace((stringp(a->block_commit)? a->block_commit : "no explanation given"), "-", " "));
-
return
1;
+
err
=
1;
+
continue;
} } if(a->ident && a->ident != GitAttributes.ATTR_FALSE && a->ident != GitAttributes.ATTR_UNSET) {
-
if (check_ident(filename))
-
return
1;
+
if (check_ident(filename))
{
+
err
=
1;
+
continue;
} }
-
return 0;
+
}
-
+
return err;
+
}
int check_gitattributes_files() {
-
+
int err = 0;
foreach(files_to_commit, string filename) if(has_suffix(filename, "/.gitattributes")) { write(".gitattributes are not allowed in subdirectories; " "please remove %s\n", filename);
-
return
1;
+
err
=
1;
} if(search(files_to_commit, ".gitattributes")>=0) {
411:
foreach(added_fi, string path) { if(!has_prefix(path, "/") || search(path, "*")>=0) { write("Commit adds unsupported foreign_ident: %s\n", path);
-
return
1;
+
err
=
1;
+
continue;
} path = path[1..]; if (!entry_is_new(path)) { write("Commit adds foreign_ident to existing file %s\n", path);
-
return
1;
+
err
=
1;
} }
426:
if (search(files_to_commit, path)<0 && find_expanded_ident(get_file(path, 1))) { write("Commit removes foreign_ident from unchanged file %s\n", path);
-
return
1;
+
err
=
1;
} } }
-
return
0
;
+
return
err
;
} }
465:
split_z(run_git("diff", "--name-only", "-z", sha, sha+"^")); attrs = GitAttributes(get_file(".gitattributes", 1)); string ts_test = check_commit_timestamps(sha);
+
int err = 0;
if (ts_test) { write("Invalid timestamps: %s\n", ts_test);
-
return
1;
+
err
=
1;
} string cm_test = check_commit_msg(sha); if (cm_test) { write("Commit message encoding problem:\n%s", cm_test);
-
return
1;
+
err
=
1;
}
-
return check_blocker_attributes() |
|
-
check_gitattributes_files();
+
return check_blocker_attributes() |
+
check_gitattributes_files()
|
+
err
;
} }
514:
split_z(run_git("diff", "--staged", "--name-only", "-z")); attrs = GitAttributes(get_file(".gitattributes", 1)); return
-
check_attributes_staged() |
|
-
check_blocker_attributes() |
|
+
check_attributes_staged() |
+
check_blocker_attributes() |
check_gitattributes_files(); } }