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:
parent
3ffda9e290
commit
5c3cca63c4
@ -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)
|
||||
|
@ -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, [])
|
||||
|
@ -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")
|
||||
|
||||
|
1
tests/addfile_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/addfile_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/commit_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/commit_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/deletefile_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/deletefile_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/difffile_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/difffile_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/prdiff_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/prdiff_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/prdiff_fixtures/some:project/.osc/_osclib_version
Normal file
1
tests/prdiff_fixtures/some:project/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/repairwc_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/repairwc_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
@ -0,0 +1 @@
|
||||
1.0
|
@ -0,0 +1 @@
|
||||
1.0
|
1
tests/revertfile_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/revertfile_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
1
tests/update_fixtures/osctest/.osc/_osclib_version
Normal file
1
tests/update_fixtures/osctest/.osc/_osclib_version
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
Loading…
Reference in New Issue
Block a user