forked from importers/git-importer
Import packages links point to
This commit is contained in:
parent
e8094cbc68
commit
fb130bbf6f
@ -127,15 +127,15 @@ class Importer:
|
||||
root = self.obs._history(project, package)
|
||||
if root is None:
|
||||
return
|
||||
latest = DBRevision.latest_revision(db, project, self.package)
|
||||
latest = DBRevision.latest_revision(db, project, package)
|
||||
for r in root.findall("revision"):
|
||||
rev = OBSRevision(self.obs, self, project, self.package).parse(r)
|
||||
rev = OBSRevision(self.obs, self, project, package).parse(r)
|
||||
if not latest or rev.rev > latest.rev:
|
||||
dbrev = DBRevision.import_obs_rev(db, rev)
|
||||
root = rev.read_link()
|
||||
if root:
|
||||
tprj = root.get("project") or project
|
||||
tpkg = root.get("package") or self.package
|
||||
tpkg = root.get("package") or package
|
||||
dbrev.links_to(db, tprj, tpkg)
|
||||
db.conn.commit()
|
||||
|
||||
@ -144,6 +144,15 @@ class Importer:
|
||||
for project, _, api_url in self.projects:
|
||||
self.obs.change_url(api_url)
|
||||
self.update_db_package(db, project, self.package)
|
||||
cur = db.cursor()
|
||||
cur.execute(
|
||||
"SELECT DISTINCT l.project, l.package from links l join revisions r on r.id=l.revision_id WHERE r.project=%s AND r.package=%s",
|
||||
(project, self.package),
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
(lproject, lpackage) = row
|
||||
self.update_db_package(db, lproject, lpackage)
|
||||
cur.close()
|
||||
|
||||
def import_all_revisions(self, gc):
|
||||
# Fetch all the requests and sort them. Ideally we should
|
||||
|
@ -64,7 +64,8 @@ class OBSRevision:
|
||||
def read_link(self):
|
||||
try:
|
||||
return self.obs._xml(
|
||||
f"source/{self.project}/{self.package}/_link", rev=self.srcmd5
|
||||
f"source/{self.project}/{self.package}/_link",
|
||||
rev=self.unexpanded_srcmd5,
|
||||
)
|
||||
except HTTPError as e:
|
||||
if e.code == 404:
|
||||
@ -81,7 +82,7 @@ class OBSRevision:
|
||||
target_project = root.get("project")
|
||||
except ET.ParseError:
|
||||
logging.error(
|
||||
f"_link can't be parsed [{self.project}/{self.package} rev={self.srcmd5}]"
|
||||
f"_link can't be parsed [{self.project}/{self.package} rev={self.unexpanded_srcmd5}]"
|
||||
)
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user