[Reproducible-commits] [diffoscope] 03/04: Make directory comparison work again
Jérémy Bobbio
lunar at moszumanska.debian.org
Thu Sep 3 09:40:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository diffoscope.
commit 6502dd0df83fc8a2ba1c21d1de948559fb31b5d6
Author: Jérémy Bobbio <lunar at debian.org>
Date: Thu Sep 3 09:38:04 2015 +0000
Make directory comparison work again
It was broken for anything except directories ending with '/' since 618cc39a5.
---
diffoscope/comparators/directory.py | 4 ++--
tests/comparators/test_directory.py | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index f7bee42..1ce28ea 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -159,7 +159,7 @@ class DirectoryContainer(Container):
@contextmanager
def open(self):
with self.source.get_content():
- self._path = self.source.path
+ self._path = self.source.path.rstrip('/') or '/'
yield self
self._path = None
@@ -169,7 +169,7 @@ class DirectoryContainer(Container):
if root == self._path:
root = ''
else:
- root = root[len(os.path.commonprefix((root, self._path))):]
+ root = root[len(self._path) + 1:]
names.extend([os.path.join(root, f) for f in files])
return names
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index cf62c1e..2ea46ba 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -34,6 +34,10 @@ def test_no_differences():
difference = compare_directories(os.path.dirname(__file__), os.path.dirname(__file__))
assert difference is None
+def test_no_differences_with_extra_slash():
+ difference = compare_directories(os.path.dirname(__file__) + '/', os.path.dirname(__file__))
+ assert difference is None
+
@pytest.fixture
def differences(tmpdir):
tmpdir.mkdir('a')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the Reproducible-commits
mailing list