diff --git a/osc/obs_scm/package.py b/osc/obs_scm/package.py
index 36c06815f1..e72880f596 100644
--- a/osc/obs_scm/package.py
+++ b/osc/obs_scm/package.py
@@ -1573,16 +1573,18 @@ def init_package(apiurl: str, project, package, dir, size_limit=None, meta=False
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', '' + '\n')
- store_write_string(dir, '_osclib_version', __store_version__ + '\n')
+ s.write_string("_files", "")
return Package(dir, progress_obj=progress_obj, size_limit=size_limit)
diff --git a/osc/obs_scm/project.py b/osc/obs_scm/project.py
index 0623a71293..60c712ff55 100644
--- a/osc/obs_scm/project.py
+++ b/osc/obs_scm/project.py
@@ -624,10 +624,12 @@ def init_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, [])
diff --git a/osc/obs_scm/store.py b/osc/obs_scm/store.py
index e8437e5da2..8c4a6a065e 100644
--- a/osc/obs_scm/store.py
+++ b/osc/obs_scm/store.py
@@ -42,6 +42,9 @@ def __init__(self, path, check=True):
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")
diff --git a/tests/addfile_fixtures/osctest/.osc/_osclib_version b/tests/addfile_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/addfile_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/commit_fixtures/osctest/.osc/_osclib_version b/tests/commit_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/commit_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/deletefile_fixtures/osctest/.osc/_osclib_version b/tests/deletefile_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/deletefile_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/difffile_fixtures/osctest/.osc/_osclib_version b/tests/difffile_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/difffile_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/prdiff_fixtures/home:user:branches:some:project/.osc/_osclib_version b/tests/prdiff_fixtures/home:user:branches:some:project/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/prdiff_fixtures/home:user:branches:some:project/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/prdiff_fixtures/osctest/.osc/_osclib_version b/tests/prdiff_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/prdiff_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/prdiff_fixtures/some:project/.osc/_osclib_version b/tests/prdiff_fixtures/some:project/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/prdiff_fixtures/some:project/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/project_package_status_fixtures/osctest/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/project_package_status_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/repairwc_fixtures/osctest/.osc/_osclib_version b/tests/repairwc_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/repairwc_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_osclib_version b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/repairwc_fixtures/prj_noapiurl/.osc/_osclib_version b/tests/repairwc_fixtures/prj_noapiurl/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/repairwc_fixtures/prj_noapiurl/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/revertfile_fixtures/osctest/.osc/_osclib_version b/tests/revertfile_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/revertfile_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0
diff --git a/tests/test_commandline.py b/tests/test_commandline.py
index bb86b896a6..f90e2e4071 100644
--- a/tests/test_commandline.py
+++ b/tests/test_commandline.py
@@ -143,6 +143,8 @@ class TestMainCommand(OscMainCommand):
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 @@ def test_default_arch(self):
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 @@ def test_working_copy_optional_arch(self):
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
diff --git a/tests/test_init_package.py b/tests/test_init_package.py
index ec6c5f0558..7fd92ec3a8 100644
--- a/tests/test_init_package.py
+++ b/tests/test_init_package.py
@@ -56,7 +56,7 @@ def test_meta_mode(self):
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'), '\n')
diff --git a/tests/test_store.py b/tests/test_store.py
index 90fa5f3c97..c3dde669c1 100644
--- a/tests/test_store.py
+++ b/tests/test_store.py
@@ -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 @@ def test_contains(self):
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 @@ def test_osclib_version(self):
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):
diff --git a/tests/update_fixtures/osctest/.osc/_osclib_version b/tests/update_fixtures/osctest/.osc/_osclib_version
new file mode 100644
index 0000000000..d3827e75a5
--- /dev/null
+++ b/tests/update_fixtures/osctest/.osc/_osclib_version
@@ -0,0 +1 @@
+1.0