Skip to content

Commit

Permalink
Fix a crash in 'Fix handling empty vm_type in Store.last_buildroot' w…
Browse files Browse the repository at this point in the history
…hen last_buildroot is empty
  • Loading branch information
dmach committed Sep 25, 2023
1 parent 641b365 commit ee725ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion osc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit ee725ff

Please sign in to comment.