[Reproducible-commits] [notes] 01/01: pre-receive: add initial Git pre-receive hook
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jan 14 17:23:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository notes.
commit b986c5217561d1bc64274b0041e70d65bc3ee5a0
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Jan 14 18:22:52 2015 +0100
pre-receive: add initial Git pre-receive hook
---
hooks/pre-receive | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/hooks/pre-receive b/hooks/pre-receive
new file mode 100755
index 0000000..2ef4bba
--- /dev/null
+++ b/hooks/pre-receive
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+from __future__ import print_function
+
+import os.path
+import subprocess
+import sys
+import yaml
+
+def read_from_git(ref, path):
+ return subprocess.check_output(
+ ['git', 'show', '%s:%s' % (ref, path)],
+ shell=False, close_fds=True)
+
+def validate_issues(issues):
+ for name, data in issues.iteritems():
+ if 'description' not in data:
+ print('ERROR: issue %s is missing a description' % name, file=sys.stderr)
+ sys.exit(1)
+
+def ensure_issues_are_known(issues, packages):
+ for package, data in packages.iteritems():
+ for issue in data.get('issues', []):
+ if issue not in issues:
+ print('ERROR: issue %s not listed in issues.yml' % issue, file=sys.stderr)
+ sys.exit(1)
+
+def main():
+ for ref_line in sys.stdin:
+ old_value, new_value, ref_name = ref_line.strip().split(' ', 3)
+ issues = yaml.load(read_from_git(new_value, 'issues.yml'))
+ packages = yaml.load(read_from_git(new_value, 'packages.yml'))
+ validate_issues(issues)
+ ensure_issues_are_known(issues, packages)
+
+if __name__ == '__main__':
+ main()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/notes.git
More information about the Reproducible-commits
mailing list