From 5cefb37405522445e27cb5a396626c3bb4aa680d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 1 Jun 2017 10:36:29 -0400 Subject: [PATCH] fix the way we handle deleted notes The aggregated change information for a deleted note includes the SHA as well as the filename. Extract both from the tuple separately so the path value is set correctly to a filename. Change-Id: I41fb4a7a0f6d24af47c8f059945b9bf45f859f15 Signed-off-by: Doug Hellmann --- .../notes/fix-delete-handling-55232c50b647aa57.yaml | 6 ++++++ reno/scanner.py | 4 ++-- reno/tests/test_scanner.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-delete-handling-55232c50b647aa57.yaml diff --git a/releasenotes/notes/fix-delete-handling-55232c50b647aa57.yaml b/releasenotes/notes/fix-delete-handling-55232c50b647aa57.yaml new file mode 100644 index 0000000..eaca402 --- /dev/null +++ b/releasenotes/notes/fix-delete-handling-55232c50b647aa57.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Correct a problem with handling deleted release notes that + triggered a TypeError with a message like "Can't mix strings and + bytes in path components" \ No newline at end of file diff --git a/reno/scanner.py b/reno/scanner.py index 2df1166..2f1587a 100644 --- a/reno/scanner.py +++ b/reno/scanner.py @@ -176,7 +176,7 @@ class _ChangeAggregator(object): path = c.old.path.decode('utf-8') if c.old.path else None if _note_file(path): uid = _get_unique_id(path) - by_uid[uid].append((c.type, path)) + by_uid[uid].append((c.type, path, sha)) else: LOG.debug('ignoring') elif c.type == diff_tree.CHANGE_MODIFY: @@ -1013,7 +1013,7 @@ class Scanner(object): tracker.add(fullpath, sha, current_version) elif c_type == diff_tree.CHANGE_DELETE: - path = change[-1] + path, blob_sha = change[-2:] fullpath = os.path.join(notesdir, path) tracker.delete(fullpath, sha, current_version) diff --git a/reno/tests/test_scanner.py b/reno/tests/test_scanner.py index 486d1a0..a9f8a36 100644 --- a/reno/tests/test_scanner.py +++ b/reno/tests/test_scanner.py @@ -1883,7 +1883,7 @@ class AggregateChangesTest(Base): ] results = list(self.aggregator.aggregate_changes(entry, changes)) self.assertEqual( - [('%016x' % n, 'delete', name)], + [('%016x' % n, 'delete', name, entry.commit.id)], results, )