mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-09 20:45:47 +01:00
Merge pull request #1412 from dmach/fix-store-last_buildroot-vm_type-None
Fix handling empty vm_type in Store.last_buildroot
This commit is contained in:
commit
641b365f38
@ -179,7 +179,7 @@ class OscOptions(BaseModel):
|
|||||||
|
|
||||||
if not value.strip():
|
if not value.strip():
|
||||||
if field.is_optional:
|
if field.is_optional:
|
||||||
setattr(self, field_name, value)
|
setattr(self, field_name, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
if field.origin_type is Password:
|
if field.origin_type is Password:
|
||||||
|
@ -119,7 +119,7 @@ class Store:
|
|||||||
if not isinstance(value, (list, tuple)):
|
if not isinstance(value, (list, tuple)):
|
||||||
msg = f"The argument `value` should be list, not {type(value).__name__}"
|
msg = f"The argument `value` should be list, not {type(value).__name__}"
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
value = "".join((f"{line}\n" for line in value))
|
value = "".join((f"{line or ''}\n" for line in value))
|
||||||
self.write_file(fn, value, subdir=subdir)
|
self.write_file(fn, value, subdir=subdir)
|
||||||
|
|
||||||
def read_string(self, fn, subdir=None):
|
def read_string(self, fn, subdir=None):
|
||||||
@ -291,6 +291,8 @@ class Store:
|
|||||||
if items is not None and len(items) != 3:
|
if items is not None and len(items) != 3:
|
||||||
msg = f"Package '{self.path}' contains _last_buildroot metadata that doesn't contain 3 lines: [repo, arch, vm_type]"
|
msg = f"Package '{self.path}' contains _last_buildroot metadata that doesn't contain 3 lines: [repo, arch, vm_type]"
|
||||||
raise oscerr.NoWorkingCopy(msg)
|
raise oscerr.NoWorkingCopy(msg)
|
||||||
|
if items[2] in ("", "None"):
|
||||||
|
items[2] = None
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@last_buildroot.setter
|
@last_buildroot.setter
|
||||||
|
@ -36,6 +36,14 @@ class TestGitStore(unittest.TestCase):
|
|||||||
store = GitStore(self.tmpdir)
|
store = GitStore(self.tmpdir)
|
||||||
self.assertEqual(store.last_buildroot, ("repo", "arch", "vm_type"))
|
self.assertEqual(store.last_buildroot, ("repo", "arch", "vm_type"))
|
||||||
|
|
||||||
|
def test_last_buildroot_empty_vm_type(self):
|
||||||
|
store = GitStore(self.tmpdir)
|
||||||
|
self.assertEqual(store.last_buildroot, None)
|
||||||
|
store.last_buildroot = ("repo", "arch", None)
|
||||||
|
|
||||||
|
store = GitStore(self.tmpdir)
|
||||||
|
self.assertEqual(store.last_buildroot, ("repo", "arch", None))
|
||||||
|
|
||||||
def test_scmurl(self):
|
def test_scmurl(self):
|
||||||
store = GitStore(self.tmpdir)
|
store = GitStore(self.tmpdir)
|
||||||
self.assertEqual(store.scmurl, "https://example.com/packages/my-package.git")
|
self.assertEqual(store.scmurl, "https://example.com/packages/my-package.git")
|
||||||
|
@ -203,6 +203,12 @@ class TestStore(unittest.TestCase):
|
|||||||
store2 = Store(self.tmpdir)
|
store2 = Store(self.tmpdir)
|
||||||
self.assertEqual(store2.last_buildroot, ["repo", "arch", "vm_type"])
|
self.assertEqual(store2.last_buildroot, ["repo", "arch", "vm_type"])
|
||||||
|
|
||||||
|
self.store.last_buildroot = "repo", "arch", None
|
||||||
|
self.fileEquals("_last_buildroot", "repo\narch\n\n")
|
||||||
|
|
||||||
|
store2 = Store(self.tmpdir)
|
||||||
|
self.assertEqual(store2.last_buildroot, ["repo", "arch", None])
|
||||||
|
|
||||||
def test_meta_node(self):
|
def test_meta_node(self):
|
||||||
self.store.write_string(
|
self.store.write_string(
|
||||||
"_meta",
|
"_meta",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user