From ee725ff51b8362c688c766716b89a1ecf1be0e5a Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 25 Sep 2023 14:41:17 +0200 Subject: [PATCH] Fix a crash in 'Fix handling empty vm_type in Store.last_buildroot' when last_buildroot is empty --- osc/store.py | 7 ++++++- tests/test_store.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/osc/store.py b/osc/store.py index 3aad42c5ee..29eeb34a21 100644 --- a/osc/store.py +++ b/osc/store.py @@ -288,11 +288,16 @@ def files(self, value): def last_buildroot(self): self.assert_is_package() items = self.read_list("_last_buildroot") - if items is not None and len(items) != 3: + if items is None: + return items + + if len(items) != 3: msg = f"Package '{self.path}' contains _last_buildroot metadata that doesn't contain 3 lines: [repo, arch, vm_type]" raise oscerr.NoWorkingCopy(msg) + if items[2] in ("", "None"): items[2] = None + return items @last_buildroot.setter diff --git a/tests/test_store.py b/tests/test_store.py index c5eb9db98b..90fa5f3c97 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -193,6 +193,8 @@ def test_files(self): self.assertTrue(files2[1] == files[0]) def test_last_buildroot(self): + self.assertEqual(self.store.last_buildroot, None) + self.store.last_buildroot = "repo", "arch", "vm_type" self.fileEquals("_last_buildroot", "repo\narch\nvm_type\n")