[misc] 01/01: generate suggested labels; (...)

Chris West faux-guest at moszumanska.debian.org
Sat May 6 16:11:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

faux-guest pushed a commit to branch master
in repository misc.

commit a40467c2a77a2ba033e8b0e97617912015dddc1f
Author: Chris West (Faux) <git at goeswhere.com>
Date:   Sat May 6 18:11:48 2017 +0200

    generate suggested labels; (...)
    
    Doesn't work so well, due to the confusion about where the length truncation happens.
---
 has-only.py | 54 ++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 14 deletions(-)

diff --git a/has-only.py b/has-only.py
index c3d1d8a..43475a0 100755
--- a/has-only.py
+++ b/has-only.py
@@ -4,13 +4,15 @@ import itertools
 import json
 import re
 import sys
-from typing import Iterator, Tuple, Optional
+from typing import Iterator, Tuple, Optional, Set
 
 DO_FILE_PREFIX = '├── '
 DO_DIFF_PREFIX = re.compile('(?:│ )+([+-])(.*)')
 XXD_LINE = re.compile('[0-9a-f]{8}: (?:[0-9a-f]{4} ){8} (.{16})')
 XXD_END = re.compile('[0-9a-f]{8}: [0-9a-f]{2}(?:[0-9a-f]{2}|  ) (?:[0-9a-f ]{4} ){7} (.{1,16})')
 
+PACKAGE_FROM_PATH = re.compile('.*/([a-z0-9.+-]+)_[^/]+')
+
 TOO_BIG = 1024 * 50
 
 
@@ -115,15 +117,21 @@ def warn(path, msg):
     sys.stderr.write('{}: {}\n'.format(path, msg))
 
 
-def explain_build_path(file_problems: Iterator[Tuple[str, Tuple[str, ...]]]):
-    problems = set(probs for _, probs in file_problems)
-    if () in problems:
-        warn(path, 'unclassified problems')
-        return
+def suggest_notes(file_problems: Iterator[Tuple[str, Tuple[str, ...]]]) -> Optional[Set[str]]:
+    problems = set(tuple(sorted(probs)) for _, probs, _, _ in file_problems)
+
+    if 1 == len(problems) and ('build_id',) in problems:
+        return {'build_id_differences_only'}
+
+    notes = set()
+    distinct_labels = set(x for y in problems for x in y)
+    if 'build_path' in distinct_labels:
+        notes.add('captures_build_path')
+
+    if 'auto_shell' in distinct_labels:
+        notes.add('captures_shell_variable_in_autofoo_script')
 
-    # if 1 == len(problems) and ('build_id',) in problems:
-    if 'build_path' not in (x for y in problems for x in y):
-        print(path)
+    return notes
 
 
 def find_interesting(file_problems: Iterator) -> Optional[Tuple]:  # or something
@@ -134,23 +142,41 @@ def find_interesting(file_problems: Iterator) -> Optional[Tuple]:  # or somethin
     return None
 
 
+def package_from(path: str) -> str:
+    return PACKAGE_FROM_PATH.match(path).group(1)
+
+
 def main():
-    out = []
+    int_diffs = []
+    suggested_notes = {}
     for path in sys.argv[1:]:
         try:
             with open(path) as f:
-                file_problems = process(f)
-                interesting = find_interesting(file_problems)
+                file_problems = list(process(f))
 
+            interesting = find_interesting(file_problems)
             if interesting:
-                out.append([path] + list(interesting))
+                int_diffs.append([path] + list(interesting))
+
+            notes = suggest_notes(file_problems)
+            if notes:
+                suggested_notes[package_from(path)] = notes
 
         except Exception as e:
             warn(path, 'failure:')
             raise
 
     with open('intdiffs.json', 'w') as f:
-        json.dump(out, f)
+        json.dump(int_diffs, f)
+
+    with open('suggested_notes.yml', 'w') as f:
+        for pkg in sorted(suggested_notes.keys()):
+            f.write(pkg)
+            f.write(':\n  issues:\n')
+            for note in suggested_notes[pkg]:
+                f.write('    - ')
+                f.write(note)
+                f.write('\n')
 
 
 if '__main__' == __name__:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git



More information about the Reproducible-commits mailing list