forked from adamm/git-importer
Store API URL in the revision table
Will be important once we get into SLE
This commit is contained in:
@@ -26,6 +26,7 @@ class DBRevision:
|
||||
self.request_number,
|
||||
self.request_id,
|
||||
self.files_hash,
|
||||
self.api_url,
|
||||
) = row
|
||||
self.rev = float(self.rev)
|
||||
self._files = None
|
||||
@@ -67,6 +68,7 @@ class DBRevision:
|
||||
"comment": self.comment,
|
||||
"broken": self.broken,
|
||||
"expanded_srcmd5": self.expanded_srcmd5,
|
||||
"api_url": self.api_url,
|
||||
"files_hash": self.files_hash,
|
||||
"files": self.files_list(),
|
||||
}
|
||||
@@ -85,8 +87,8 @@ class DBRevision:
|
||||
def import_obs_rev(db: DB, revision: OBSRevision):
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
"""INSERT INTO revisions (project, package, rev, unexpanded_srcmd5, commit_time, userid, comment, request_number)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
"""INSERT INTO revisions (project, package, rev, unexpanded_srcmd5, commit_time, userid, comment, request_number, api_url)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(
|
||||
revision.project,
|
||||
revision.package,
|
||||
@@ -96,6 +98,7 @@ class DBRevision:
|
||||
revision.userid,
|
||||
revision.comment,
|
||||
revision.request_number,
|
||||
revision.obs.url,
|
||||
),
|
||||
)
|
||||
return DBRevision.fetch_revision(
|
||||
@@ -104,6 +107,8 @@ class DBRevision:
|
||||
|
||||
@staticmethod
|
||||
def fetch_revision(db, project, package, rev):
|
||||
"""Technically we would need the api_url as well, but we assume projects are unique
|
||||
(e.g. not importing SLE from obs)"""
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
"SELECT * FROM revisions where project=%s and package=%s and rev=%s",
|
||||
@@ -266,9 +271,9 @@ class DBRevision:
|
||||
"""Used in test cases to read a revision from fixtures into the test database"""
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
"""INSERT INTO revisions (project, package, rev, unexpanded_srcmd5, expanded_srcmd5,
|
||||
commit_time, userid, comment, broken, files_hash)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id""",
|
||||
"""INSERT INTO revisions (project, package, rev, unexpanded_srcmd5, expanded_srcmd5,
|
||||
commit_time, userid, comment, broken, files_hash, api_url)
|
||||
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id""",
|
||||
(
|
||||
rev_dict["project"],
|
||||
rev_dict["package"],
|
||||
@@ -280,6 +285,7 @@ class DBRevision:
|
||||
rev_dict["comment"],
|
||||
rev_dict["broken"],
|
||||
rev_dict["files_hash"],
|
||||
rev_dict.get("api_url", "https://api.opensuse.org"),
|
||||
),
|
||||
)
|
||||
rev_id = cur.fetchone()[0]
|
||||
|
Reference in New Issue
Block a user