[Reproducible-commits] [notes] 01/01: Work around lack of python-yaml on moszumanska

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jan 14 17:49:53 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 f44f7a60c3e57cd7ff598763d91914f06545a9be
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jan 14 18:49:10 2015 +0100

    Work around lack of python-yaml on moszumanska
---
 hooks/pre-receive | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/hooks/pre-receive b/hooks/pre-receive
index 2ef4bba..d52ca11 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -5,7 +5,11 @@ from __future__ import print_function
 import os.path
 import subprocess
 import sys
-import yaml
+
+# not available on Aliath (yet?)
+#import yaml
+# XXX:
+import json
 
 def read_from_git(ref, path):
     return subprocess.check_output(
@@ -25,11 +29,21 @@ def ensure_issues_are_known(issues, packages):
                 print('ERROR: issue %s not listed in issues.yml' % issue, file=sys.stderr)
                 sys.exit(1)
 
+def yaml_load(content):
+    cmd = ['ruby', '-ryaml', '-rjson', '-e', 'print JSON.dump(YAML.load($stdin))']
+    p = subprocess.Popen(cmd, shell=False, close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    out, err = p.communicate(content)
+    p.wait()
+    if p.returncode != 0:
+        print("%s failed with %d. Output:\n%s\n" % (cmd, p.returncode, out), file=sys.stderr)
+        sys.exit(2)
+    return json.loads(out)
+
 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'))
+        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)
 

-- 
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