[misc] 01/02: has-only: trying to find first interesting diff

Chris West faux-guest at moszumanska.debian.org
Sat May 6 10:08:40 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 322031b065aff7eeb6b96a304df51f959f8b0f1b
Author: Chris West (Faux) <git at goeswhere.com>
Date:   Sat May 6 10:44:10 2017 +0100

    has-only: trying to find first interesting diff
---
 has-only.py | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/has-only.py b/has-only.py
index 9658616..794a227 100755
--- a/has-only.py
+++ b/has-only.py
@@ -1,14 +1,18 @@
 #!/usr/bin/python3
 
 import itertools
+import json
 import sys
 import re
 
+from typing import Iterator, Tuple, List, Optional
+
 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})')
 
+
 def diff_parse(lines):
     file = None
     in_add = False
@@ -38,6 +42,7 @@ def diff_parse(lines):
             replacing = []
             replacement = []
 
+
 def strip_xxd(lines):
     stripped = ''
     for no, line in enumerate(lines):
@@ -53,6 +58,7 @@ def strip_xxd(lines):
 
     return stripped
 
+
 def process(f):
     has = set()
     hunks = diff_parse(f)
@@ -60,7 +66,13 @@ def process(f):
     for file, before, after in without_xxd:
         has = set()
 
-        if file in {'file list', 'md5sums', 'Files', './control', 'line order'}:
+        if file in {
+                'file list',
+                'md5sums',
+                'Files',
+                './control',
+                'line order',
+                'zipinfo'}:
             # TODO: this is a massive approximation; ignores variations like deleting a file
             continue
 
@@ -80,7 +92,7 @@ def process(f):
                 or file.endswith('.rdx-content'):
             has.add('rdb')
 
-        yield tuple(sorted(has))
+        yield (file, has, before, after)
         #if not has:
         #    raise Exception("unclassified: {}".format((file, before, after)))
 
@@ -88,24 +100,43 @@ 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
+
+    #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)
+
+
+def find_interesting(file_problems: Iterator) -> Optional[Tuple]: # or something
+    for file, problems, before, after in file_problems:
+        if not problems:
+            return file, before, after
+
+    return None
+
+
+
 def main():
+    out = []
     for path in sys.argv[1:]:
         try:
             with open(path) as f:
-                problems = set(process(f))
-            if () in problems:
-                warn(path, 'unclassified problems')
-                continue
+                file_problems = process(f)
+                interesting = find_interesting(file_problems)
 
-            #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)
-                continue
+            if interesting:
+                out.append([path] + list(interesting))
 
-            warn(path, 'other problems: {}'.format(problems))
         except Exception as e:
             warn(path, 'failure:')
             raise
 
+    with open('intdiffs.json', 'w') as f:
+        json.dump(out, f)
+
 if '__main__' == __name__:
     main()

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