[Reproducible-commits] [debbindiff] 05/08: When comparing .changes, match names without version numbers

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Jul 31 08:54:51 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit acf86ca4b3d2f1dac1634d0a06af5914f31b0ed9
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Fri Jul 31 07:33:02 2015 +0000

    When comparing .changes, match names without version numbers
    
    To make debbindiff more useful when comparing different versions
    of a package, we now find files to compare in a .changes by
    removing the version number.
    
    This should make pabs happy. :)
---
 debbindiff/comparators/debian.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/debbindiff/comparators/debian.py b/debbindiff/comparators/debian.py
index e15b47f..d17ede0 100644
--- a/debbindiff/comparators/debian.py
+++ b/debbindiff/comparators/debian.py
@@ -82,6 +82,28 @@ class DotChangesContainer(Container):
     def get_member(self, member_name):
         return DotChangesMember(self, member_name)
 
+    TRIM_RE = re.compile(r'^([^_]+)_\w[\w.+~-]*(?:_[^.]+)?(\..+)$')
+
+    @staticmethod
+    def trim_version_number(name):
+        return DotChangesContainer.TRIM_RE.sub('\\1\\2', name)
+
+    def compare(self, other, source=None):
+        differences = []
+        my_names = set(self.get_member_names())
+        my_canonical_names = dict([(DotChangesContainer.trim_version_number(name), name) for name in my_names])
+        other_names = set(other.get_member_names())
+        other_canonical_names = dict([(DotChangesContainer.trim_version_number(name), name) for name in other_names])
+        for canonical_name in sorted(set(my_canonical_names.keys()).intersection(other_canonical_names.keys())):
+            my_file = self.get_member(my_canonical_names[canonical_name])
+            other_file = other.get_member(other_canonical_names[canonical_name])
+            source = None
+            if my_canonical_names[canonical_name] == other_canonical_names[canonical_name]:
+                source = my_canonical_names[canonical_name]
+            differences.append(
+                debbindiff.comparators.compare_files(my_file, other_file, source=source))
+        return differences
+
 
 class DotChangesFile(File):
     RE_FILE_EXTENSION = re.compile(r'\.changes$')

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



More information about the Reproducible-commits mailing list