Compare commits

..

4 Commits
main ... devel

Author SHA1 Message Date
Adam Majer
94fdb3b442 Revert "Remove devel branch import"
This reverts commit 1318f9e0c4.
2024-08-11 22:54:47 +02:00
Adam Majer
f2358446da don't create gitea repos with importer 2024-08-11 22:54:44 +02:00
9660e633af Parametrizes git import parameters 2024-08-08 17:56:41 +02:00
85b9ed5e75 disable LFS check for testing 2024-08-08 17:56:17 +02:00
6 changed files with 39 additions and 18 deletions

View File

@ -1,5 +1,18 @@
sudo zypper in python3-psycopg Installation
sudo su - postgres ------------
# `createdb -O <LOCAL_USER> imported_git`
sudo zypper in python3-psycopg
sudo su - postgres
createdb -O <LOCAL_USER> imported_git`
To reset the database, drop table scheme To reset the database, drop table scheme
Gitea parameters
----------------
* `GITEA_HOST` - default: src.opensuse.org
* `GITEA_USER` - Used to generate SSH links for push. Default: gitea
* `GITEA_ORG` - target organization to push to
* `GITEA_DEFAULT_BRANCH` - default branch

View File

@ -251,16 +251,28 @@ class Git:
def add_gitea_remote(self, package): def add_gitea_remote(self, package):
repo_name = package.replace("+", "_") repo_name = package.replace("+", "_")
org_name = "pool" org_name = "rpm"
gitea_user = "gitea"
gitea_host = "src.opensuse.org"
default_branch = "factory"
if os.getenv("GITEA_HOST"):
gitea_host = getenv("GITEA_HOST")
if os.getenv("GITEA_USER"):
gitea_user = getenv("GITEA_USER")
if os.getenv("GITEA_ORG"):
org_name = getenv("GITEA_ORG")
if os.getenv("GITEA_DEFAULT_BRANCH"):
default_branch = getenv("GITEA_DEFAULT_BRANCH")
if not os.getenv("GITEA_TOKEN"): if not os.getenv("GITEA_TOKEN"):
logging.warning("Not adding a remote due to missing $GITEA_TOKEN") logging.warning("Not adding a remote due to missing $GITEA_TOKEN")
return return
url = f"https://src.opensuse.org/api/v1/org/{org_name}/repos" url = f"https://{gitea_host}/api/v1/org/{org_name}/repos"
response = requests.post( response = requests.post(
url, url,
data={"name": repo_name, "object_format_name": "sha256"}, data={"name": repo_name, "object_format_name": "sha256", "default_branch": default_branch},
headers={"Authorization": f"token {os.getenv('GITEA_TOKEN')}"}, headers={"Authorization": f"token {os.getenv('GITEA_TOKEN')}"},
timeout=10, timeout=10,
) )
@ -268,7 +280,7 @@ class Git:
# 201 Created # 201 Created
if response.status_code not in (201, 409): if response.status_code not in (201, 409):
print(response.data) print(response.data)
url = f"gitea@src.opensuse.org:{org_name}/{repo_name}.git" url = f"{gitea_user}@{gitea_host}:{org_name}/{repo_name}.git"
self.git_run( self.git_run(
["remote", "add", "origin", url], ["remote", "add", "origin", url],
) )

View File

@ -29,7 +29,7 @@ class GitExporter:
self.git.open() self.git.open()
else: else:
self.git.create() self.git.create()
self.git.add_gitea_remote(package) # self.git.add_gitea_remote(package)
self.state_file = os.path.join(self.git.path, ".git", "_flat_state.yaml") self.state_file = os.path.join(self.git.path, ".git", "_flat_state.yaml")
self.gc_interval = 200 self.gc_interval = 200
self.cachedir = cachedir self.cachedir = cachedir
@ -47,7 +47,7 @@ class GitExporter:
left_to_commit = [] left_to_commit = []
for flat in reversed(flats): for flat in reversed(flats):
found_state = False found_state = False
for branch in ["factory"]: for branch in ["factory", "devel"]:
if flat.commit.dbid == state_data.get(branch): if flat.commit.dbid == state_data.get(branch):
branch_state[branch] = flat.commit branch_state[branch] = flat.commit
flat.commit.git_commit = self.git.branch_head(branch) flat.commit.git_commit = self.git.branch_head(branch)

View File

@ -268,12 +268,9 @@ class Importer:
return self.scmsync_cache[key] return self.scmsync_cache[key]
root = self.obs._meta(key) root = self.obs._meta(key)
scmsync = None
scmsync_exists = False scmsync_exists = False
if root and root.find('scmsync') is not None: if root is not None:
scmsync = root.find('scmsync').text scmsync_exists = root.find('scmsync') is not None
if scmsync:
scmsync_exists = scmsync.startswith('https://src.opensuse.org/pool/')
self.scmsync_cache[key] = scmsync_exists self.scmsync_cache[key] = scmsync_exists
return scmsync_exists return scmsync_exists

View File

@ -83,6 +83,7 @@ class LFSOid:
self.register() self.register()
def check(self): def check(self):
return True
url = f"http://localhost:9999/check/{self.sha256}/{self.size}" url = f"http://localhost:9999/check/{self.sha256}/{self.size}"
response = requests.get( response = requests.get(
url, url,

View File

@ -36,12 +36,10 @@ def listen_events():
and "package" in body and "package" in body
and body["project"] == "openSUSE:Factory" and body["project"] == "openSUSE:Factory"
): ):
# Strip multibuild flavors if "/" in body["package"]:
package = body["package"].partition(':')[0]
if "/" in package:
return return
(MY_TASKS_DIR / package).touch() (MY_TASKS_DIR / body["package"]).touch()
print(" [x] %r:%r" % (method.routing_key, body["package"])) print(" [x] %r:%r" % (method.routing_key, body["package"]))
channel.basic_consume(queue_name, callback, auto_ack=True) channel.basic_consume(queue_name, callback, auto_ack=True)