Merge pull request 'Stop importing/exporting scmsync packages/projects' (#32) from adamm/git-importer:option_for_non_factory into main
Reviewed-on: #32 Reviewed-by: Dirk Mueller <dirkmueller@noreply@src.opensuse.org>
This commit is contained in:
commit
b3107ba3bf
@ -119,7 +119,10 @@ def main():
|
|||||||
importer = Importer(URL_OBS, args.project, args.packages)
|
importer = Importer(URL_OBS, args.project, args.packages)
|
||||||
importer.import_into_db()
|
importer.import_into_db()
|
||||||
for package in args.packages:
|
for package in args.packages:
|
||||||
export_package(args.project, package, args.repodir, args.cachedir, args.gc)
|
if not importer.package_with_scmsync(package):
|
||||||
|
export_package(args.project, package, args.repodir, args.cachedir, args.gc)
|
||||||
|
else:
|
||||||
|
logging.debug(f"{args.project}/{package} has scmsync links - skipping export")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -26,13 +26,16 @@ class Importer:
|
|||||||
# Import multiple Factory packages into the database
|
# Import multiple Factory packages into the database
|
||||||
self.packages = packages
|
self.packages = packages
|
||||||
self.project = project
|
self.project = project
|
||||||
|
self.scmsync_cache = dict()
|
||||||
|
self.packages_with_scmsync = set()
|
||||||
|
|
||||||
self.db = DB()
|
self.db = DB()
|
||||||
self.obs = OBS(api_url)
|
self.obs = OBS(api_url)
|
||||||
assert project == "openSUSE:Factory"
|
assert not self.has_scmsync(project)
|
||||||
self.refreshed_packages = set()
|
self.refreshed_packages = set()
|
||||||
self.gone_packages_set = None
|
self.gone_packages_set = None
|
||||||
|
|
||||||
|
|
||||||
def import_request(self, number):
|
def import_request(self, number):
|
||||||
self.obs.request(number).import_into_db(self.db)
|
self.obs.request(number).import_into_db(self.db)
|
||||||
|
|
||||||
@ -213,6 +216,10 @@ class Importer:
|
|||||||
return
|
return
|
||||||
logging.debug(f"Refresh {project}/{package}")
|
logging.debug(f"Refresh {project}/{package}")
|
||||||
self.refreshed_packages.add(key)
|
self.refreshed_packages.add(key)
|
||||||
|
if self.has_scmsync(project) or self.has_scmsync(key):
|
||||||
|
self.packages_with_scmsync.add(package)
|
||||||
|
logging.debug(f"{project}/{package} already in Git - skipping")
|
||||||
|
return
|
||||||
self.update_db_package(project, package)
|
self.update_db_package(project, package)
|
||||||
self.fetch_all_linked_packages(project, package)
|
self.fetch_all_linked_packages(project, package)
|
||||||
|
|
||||||
@ -255,3 +262,18 @@ class Importer:
|
|||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
self.gone_packages_set.add(line.strip())
|
self.gone_packages_set.add(line.strip())
|
||||||
return key in self.gone_packages_set
|
return key in self.gone_packages_set
|
||||||
|
|
||||||
|
def has_scmsync(self, key):
|
||||||
|
if key in self.scmsync_cache:
|
||||||
|
return self.scmsync_cache[key]
|
||||||
|
|
||||||
|
root = self.obs._meta(key)
|
||||||
|
scmsync_exists = False
|
||||||
|
if root is not None:
|
||||||
|
scmsync_exists = root.find('scmsync') is not None
|
||||||
|
self.scmsync_cache[key] = scmsync_exists
|
||||||
|
return scmsync_exists
|
||||||
|
|
||||||
|
def package_with_scmsync(self, package):
|
||||||
|
return package in self.packages_with_scmsync
|
||||||
|
|
||||||
|
10
lib/obs.py
10
lib/obs.py
@ -73,11 +73,11 @@ class OBS:
|
|||||||
logging.debug(f"GET {url}")
|
logging.debug(f"GET {url}")
|
||||||
return ET.parse(osc.core.http_GET(url)).getroot()
|
return ET.parse(osc.core.http_GET(url)).getroot()
|
||||||
|
|
||||||
def _meta(self, project, package, **params):
|
def _meta(self, key, **params):
|
||||||
try:
|
try:
|
||||||
root = self._xml(f"source/{project}/{package}/_meta", **params)
|
root = self._xml(f"source/{key}/_meta", **params)
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
logging.error(f"Package [{project}/{package} {params}] has no meta")
|
logging.error(f"Project/Package [{key} {params}] has no meta")
|
||||||
return None
|
return None
|
||||||
return root
|
return root
|
||||||
|
|
||||||
@ -118,13 +118,13 @@ class OBS:
|
|||||||
return root
|
return root
|
||||||
|
|
||||||
def exists(self, project, package):
|
def exists(self, project, package):
|
||||||
root = self._meta(project, package)
|
root = self._meta(f"{project}/{package}")
|
||||||
if root is None:
|
if root is None:
|
||||||
return False
|
return False
|
||||||
return root.get("project") == project
|
return root.get("project") == project
|
||||||
|
|
||||||
def devel_project(self, project, package):
|
def devel_project(self, project, package):
|
||||||
root = self._meta(project, package)
|
root = self._meta(f"{project}/{package}")
|
||||||
devel = root.find("devel")
|
devel = root.find("devel")
|
||||||
if devel is None:
|
if devel is None:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user