From b2cadb8c01555b47a18ae135938d72eafd843220 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Tue, 1 Nov 2022 18:44:59 +0100 Subject: [PATCH] Don't crash on packages that didn't get updates in devel --- lib/tree_builder.py | 22 +-- tests/fixtures/2048-cli-data.yaml | 189 +++++++++++++++++++++ tests/fixtures/2048-cli-expected-tree.yaml | 3 + tests/tree_test.py | 2 + 4 files changed, 206 insertions(+), 10 deletions(-) create mode 100644 tests/fixtures/2048-cli-data.yaml create mode 100644 tests/fixtures/2048-cli-expected-tree.yaml diff --git a/lib/tree_builder.py b/lib/tree_builder.py index f5b10f1..77eaf5e 100644 --- a/lib/tree_builder.py +++ b/lib/tree_builder.py @@ -175,16 +175,17 @@ class TreeBuilder: merge_before_last = last_merge last_merge = factory_node factory_node = factory_node.parent - # we need to find the last merged_into that didn't end nowhere - # and cut the rope there - node = merge_before_last.merged - last_node = None - while node: - node = node.parent - if node and node.merged_into: - break - last_node = node - last_node.parent = None + if merge_before_last: + # we need to find the last merged_into that didn't end nowhere + # and cut the rope there + node = merge_before_last.merged + last_node = None + while node: + node = node.parent + if node and node.merged_into: + break + last_node = node + last_node.parent = None if not last_merge.parent: last_merge.parent = last_merge.merged @@ -195,5 +196,6 @@ class TreeBuilder: """Create a Factory tree (returning the top)""" factory_revisions = self.revisions_chain("openSUSE:Factory", package) self.add_merge_points(factory_revisions) + #factory_revisions.print() self.prune_loose_end(factory_revisions) return factory_revisions diff --git a/tests/fixtures/2048-cli-data.yaml b/tests/fixtures/2048-cli-data.yaml new file mode 100644 index 0000000..75c5421 --- /dev/null +++ b/tests/fixtures/2048-cli-data.yaml @@ -0,0 +1,189 @@ +revisions: +- broken: false + comment: Initial package for 2048-cli + commit_time: 2019-01-17 13:24:10 + expanded_srcmd5: bf00cfcbc357fc8a22140cb976cb1831 + files: + - md5: fc83599e3bee1ca6e801c0345972e0db + mtime: 1547497445 + name: 2048-cli-0.9.1+git.20181118.tar.xz + size: 11264 + - md5: 0e55db8b846331b0419de91b9b4adeed + mtime: 1547497445 + name: 2048-cli-link-against-correct-curses-lib.patch + size: 599 + - md5: f5163dd8a1eeba70ab548a94abe5c2e8 + mtime: 1547497445 + name: 2048-cli-use-proper-gettext-header.patch + size: 295 + - md5: 66545f46846337395fef1a73ac8adc4b + mtime: 1547497445 + name: 2048-cli.changes + size: 160 + - md5: 664c5dde51c1aed237647f5ee3f33eb1 + mtime: 1547497446 + name: 2048-cli.spec + size: 1912 + - md5: 19fd04edbcba9d5dd847987cb6a252f9 + mtime: 1547497446 + name: _service + size: 576 + - md5: 17e4e2499ed0511542a3f1119f0e7f73 + mtime: 1547497446 + name: _servicedata + size: 237 + files_hash: 43709daf58d28446064513690987c5bb + package: 2048-cli + project: games + request: + creator: mnhauke + number: 666053 + source_package: 2048-cli + source_project: home:mnhauke:games + source_rev: '1' + state: accepted + type: submit + rev: 1.0 + unexpanded_srcmd5: d5865fc419f6c88f7e53304ad653a5fe + userid: dstoecker +- broken: false + comment: '- Generalize description, and adjust summary grammar.' + commit_time: 2019-01-17 16:47:56 + expanded_srcmd5: 9403af9dd3f07b99bee5230c36d73c55 + files: + - md5: fc83599e3bee1ca6e801c0345972e0db + mtime: 1547497445 + name: 2048-cli-0.9.1+git.20181118.tar.xz + size: 11264 + - md5: 0e55db8b846331b0419de91b9b4adeed + mtime: 1547497445 + name: 2048-cli-link-against-correct-curses-lib.patch + size: 599 + - md5: f5163dd8a1eeba70ab548a94abe5c2e8 + mtime: 1547497445 + name: 2048-cli-use-proper-gettext-header.patch + size: 295 + - md5: a84bd74cb2fff9e88a53763a90e5dac3 + mtime: 1547737525 + name: 2048-cli.changes + size: 348 + - md5: ae75b0d87d1636964684ec9312b5e5a4 + mtime: 1547737525 + name: 2048-cli.spec + size: 1980 + - md5: 19fd04edbcba9d5dd847987cb6a252f9 + mtime: 1547497446 + name: _service + size: 576 + - md5: 17e4e2499ed0511542a3f1119f0e7f73 + mtime: 1547497446 + name: _servicedata + size: 237 + files_hash: 376a74bc69d432aa5d9880a23bb1b1a3 + package: 2048-cli + project: games + request: + creator: jengelh + number: 666761 + source_package: 2048-cli + source_project: home:jengelh:branches:games + source_rev: '2' + state: accepted + type: submit + rev: 2.0 + unexpanded_srcmd5: f523f3b5b7fbb3f1d27139eaed4d89d3 + userid: mnhauke +- broken: false + comment: initialized devel package after accepting 666812 + commit_time: 2019-01-24 14:11:01 + expanded_srcmd5: f29bf05261449d7e67e13ad64c4e2c03 + files: + - md5: fc83599e3bee1ca6e801c0345972e0db + mtime: 1547497445 + name: 2048-cli-0.9.1+git.20181118.tar.xz + size: 11264 + - md5: 0e55db8b846331b0419de91b9b4adeed + mtime: 1547497445 + name: 2048-cli-link-against-correct-curses-lib.patch + size: 599 + - md5: f5163dd8a1eeba70ab548a94abe5c2e8 + mtime: 1547497445 + name: 2048-cli-use-proper-gettext-header.patch + size: 295 + - md5: a84bd74cb2fff9e88a53763a90e5dac3 + mtime: 1547737525 + name: 2048-cli.changes + size: 348 + - md5: ae75b0d87d1636964684ec9312b5e5a4 + mtime: 1547737525 + name: 2048-cli.spec + size: 1980 + - md5: 19fd04edbcba9d5dd847987cb6a252f9 + mtime: 1547497446 + name: _service + size: 576 + - md5: 17e4e2499ed0511542a3f1119f0e7f73 + mtime: 1547497446 + name: _servicedata + size: 237 + files_hash: 376a74bc69d432aa5d9880a23bb1b1a3 + package: 2048-cli + project: games + request: + creator: jengelh + number: 666812 + source_package: 2048-cli + source_project: games + source_rev: '2' + state: accepted + type: submit + rev: 3.0 + unexpanded_srcmd5: 6caa3b7070b6f2c5c7772d00c6ac8712 + userid: dimstar_suse +- broken: false + comment: '' + commit_time: 2019-01-24 14:11:01 + expanded_srcmd5: 00f1a7cd03864ac8f34c66c4a028d175 + files: + - md5: fc83599e3bee1ca6e801c0345972e0db + mtime: 1547497445 + name: 2048-cli-0.9.1+git.20181118.tar.xz + size: 11264 + - md5: 0e55db8b846331b0419de91b9b4adeed + mtime: 1547497445 + name: 2048-cli-link-against-correct-curses-lib.patch + size: 599 + - md5: f5163dd8a1eeba70ab548a94abe5c2e8 + mtime: 1547497445 + name: 2048-cli-use-proper-gettext-header.patch + size: 295 + - md5: a84bd74cb2fff9e88a53763a90e5dac3 + mtime: 1547737525 + name: 2048-cli.changes + size: 348 + - md5: ae75b0d87d1636964684ec9312b5e5a4 + mtime: 1547737525 + name: 2048-cli.spec + size: 1980 + - md5: 19fd04edbcba9d5dd847987cb6a252f9 + mtime: 1547497446 + name: _service + size: 576 + - md5: 17e4e2499ed0511542a3f1119f0e7f73 + mtime: 1547497446 + name: _servicedata + size: 237 + files_hash: 376a74bc69d432aa5d9880a23bb1b1a3 + package: 2048-cli + project: openSUSE:Factory + request: + creator: jengelh + number: 666812 + source_package: 2048-cli + source_project: games + source_rev: '2' + state: accepted + type: submit + rev: 1.0 + unexpanded_srcmd5: 63aac027654e164c683fa5c6684a2e00 + userid: dimstar_suse diff --git a/tests/fixtures/2048-cli-expected-tree.yaml b/tests/fixtures/2048-cli-expected-tree.yaml new file mode 100644 index 0000000..396f670 --- /dev/null +++ b/tests/fixtures/2048-cli-expected-tree.yaml @@ -0,0 +1,3 @@ +- commit: openSUSE:Factory/2048-cli/1.0 +- commit: games/2048-cli/2.0 +- commit: games/2048-cli/1.0 diff --git a/tests/tree_test.py b/tests/tree_test.py index 6c4da5f..7d763c7 100644 --- a/tests/tree_test.py +++ b/tests/tree_test.py @@ -42,6 +42,8 @@ class TestTreeMethods(unittest.TestCase): def test_llvm13_tree(self): self.verify_package("llvm13") + def test_2048_cli_tree(self): + self.verify_package("2048-cli") if __name__ == "__main__": unittest.main()