1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-25 22:36:13 +01:00

Run check_store_version() in obs_scm.Store and fix related code in Project and Package

This commit is contained in:
Daniel Mach 2024-06-24 08:36:46 +02:00
parent 3ffda9e290
commit 5c3cca63c4
19 changed files with 43 additions and 15 deletions

View File

@ -1573,16 +1573,18 @@ rev: %s
raise oscerr.OscIOError(None, f'error: \'{dir}\' is already an initialized osc working copy')
else:
os.mkdir(os.path.join(dir, store))
store_write_project(dir, project)
store_write_string(dir, '_package', package + '\n')
Store(dir).apiurl = apiurl
s = Store(dir, check=False)
s.write_string("_osclib_version", Store.STORE_VERSION)
s.apiurl = apiurl
s.project = project
s.package = package
if meta:
store_write_string(dir, '_meta_mode', '')
s.write_string("_meta_mode", "")
if size_limit:
store_write_string(dir, '_size_limit', str(size_limit) + '\n')
s.size_limit = int(size_limit)
if scm_url:
Store(dir).scmurl = scm_url
s.scmurl = scm_url
else:
store_write_string(dir, '_files', '<directory />' + '\n')
store_write_string(dir, '_osclib_version', __store_version__ + '\n')
s.write_string("_files", "<directory />")
return Package(dir, progress_obj=progress_obj, size_limit=size_limit)

View File

@ -624,10 +624,12 @@ class Project:
else:
os.mkdir(os.path.join(dir, store))
store_write_project(dir, project)
Store(dir).apiurl = apiurl
s = Store(dir, check=False)
s.write_string("_osclib_version", Store.STORE_VERSION)
s.apiurl = apiurl
s.project = project
if scm_url:
Store(dir).scmurl = scm_url
s.scmurl = scm_url
package_tracking = None
if package_tracking:
store_write_initial_packages(dir, project, [])

View File

@ -42,6 +42,9 @@ class Store:
self.path = path
self.abspath = os.path.abspath(self.path)
if check:
check_store_version(self.abspath)
self.is_project = self.exists("_project") and not self.exists("_package")
self.is_package = self.exists("_project") and self.exists("_package")

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -0,0 +1 @@
1.0

View File

@ -143,6 +143,8 @@ class TestCommandClasses(unittest.TestCase):
class TestPopProjectPackageFromArgs(unittest.TestCase):
def _write_store(self, project=None, package=None):
store = Store(self.tmpdir, check=False)
store.write_string("_osclib_version", Store.STORE_VERSION)
store.apiurl = "http://localhost"
if project:
store.project = project
store.is_project = True
@ -408,6 +410,8 @@ class TestPopRepositoryArchFromArgs(unittest.TestCase):
class TestPopProjectPackageRepositoryArchFromArgs(unittest.TestCase):
def _write_store(self, project=None, package=None):
store = Store(self.tmpdir, check=False)
store.write_string("_osclib_version", Store.STORE_VERSION)
store.apiurl = "http://localhost"
if project:
store.project = project
store.is_project = True
@ -609,6 +613,8 @@ class TestPopProjectPackageRepositoryArchFromArgs(unittest.TestCase):
class TestPopProjectPackageTargetProjectTargetPackageFromArgs(unittest.TestCase):
def _write_store(self, project=None, package=None):
store = Store(self.tmpdir, check=False)
store.write_string("_osclib_version", Store.STORE_VERSION)
store.apiurl = "http://localhost"
if project:
store.project = project
store.is_project = True

View File

@ -56,7 +56,7 @@ class TestInitPackage(OscTestCase):
osc.core.Package.init_package('http://localhost', 'osctest', 'testpkg', pac_dir, meta=True)
storedir = os.path.join(pac_dir, osc.core.store)
self.assertFalse(os.path.exists(os.path.join(storedir, '_size_limit')))
self._check_list(os.path.join(storedir, '_meta_mode'), '')
self._check_list(os.path.join(storedir, '_meta_mode'), '\n')
self._check_list(os.path.join(storedir, '_project'), 'osctest\n')
self._check_list(os.path.join(storedir, '_package'), 'testpkg\n')
self._check_list(os.path.join(storedir, '_files'), '<directory />\n')

View File

@ -11,6 +11,8 @@ class TestStore(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='osc_test')
self.store = Store(self.tmpdir, check=False)
self.store.write_string("_osclib_version", Store.STORE_VERSION)
self.store.apiurl = "http://localhost"
self.store.is_package = True
self.store.project = "project name"
self.store.package = "package name"
@ -87,9 +89,9 @@ class TestStore(unittest.TestCase):
self.assertFalse("_foo" in self.store)
def test_iter(self):
self.assertEqual(len(list(self.store)), 2)
self.assertEqual(len(list(self.store)), 4)
for fn in self.store:
self.assertIn(fn, ["_project", "_package"])
self.assertIn(fn, ["_osclib_version", "_apiurl", "_project", "_package"])
def test_apiurl(self):
self.store.apiurl = "https://example.com"
@ -159,7 +161,7 @@ class TestStore(unittest.TestCase):
self.store.write_string("_osclib_version", "123")
self.fileEquals("_osclib_version", "123\n")
store2 = Store(self.tmpdir)
store2 = Store(self.tmpdir, check=False)
self.assertEqual(store2.osclib_version, "123")
def test_files(self):

View File

@ -0,0 +1 @@
1.0