1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-23 18:52:10 +01:00

Merge pull request #1414 from dmach/fix-store-last_buildroot-vm_type-None-fixup

Fix a crash in 'Fix handling empty vm_type in Store.last_buildroot' when last_buildroot is empty
This commit is contained in:
Daniel Mach 2023-09-25 22:02:27 +02:00 committed by GitHub
commit 91a30963d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -288,11 +288,16 @@ class Store:
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

View File

@ -193,6 +193,8 @@ class TestStore(unittest.TestCase):
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")