[sysadmin-bin] Handle empty repositories
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Handle empty repositories
- Date: Fri, 17 Jul 2020 12:33:39 +0000 (UTC)
commit 1eeef6afb3edac292befd4864c5fd9fd6985effb
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Fri Jul 17 14:33:13 2020 +0200
Handle empty repositories
gitlab/mirror2github | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/gitlab/mirror2github b/gitlab/mirror2github
index 5753b5d..030ad0e 100755
--- a/gitlab/mirror2github
+++ b/gitlab/mirror2github
@@ -46,26 +46,42 @@ def main():
if prj.namespace["name"] != group.id:
continue
+ print(prj.name)
mirror_settings = {
"description": f"Read-only mirror of {prj.web_url}",
"homepage": prj.web_url,
"has_issues": False,
"has_wiki": False,
- "default_branch": prj.default_branch,
}
try:
- gh_mirror = gh_org.get_repo(prj.name)
- gh_mirror.update(**mirror_settings)
+ gh_mirror = gh_org.get_repo(prj.path)
+ gh_branches = [br.name for br in gh_mirror.get_branches()]
+
+ if len(gh_branches):
+ if (
+ prj.default_branch not in gh_branches
+ and prj.default_branch != gh_mirror.default_branch
+ ):
+ gh_mirror.create_git_ref(
+ f"refs/heads/{prj.default_branch}",
+ gh_mirror.get_commit(
+ f"refs/heads/{gh_mirror.default_branch}"
+ ).sha,
+ )
+
+ gh_mirror.edit(default_branch=prj.default_branch)
+
+ gh_mirror.edit(**mirror_settings)
except UnknownObjectException:
- gh_mirror = gh_org.create_repo(prj.name, **mirror_settings)
+ print(404)
+ gh_mirror = gh_org.create_repo(prj.path, **mirror_settings)
- prj = gl.projects.get(prj.id, lazy=True)
mirrors = prj.remote_mirrors.list(all=True, lazy=True)
if not len(mirrors):
- ssh_url = f"ssh://git github com/GNOME/{prj.name}.git"
+ ssh_url = f"ssh://git github com/GNOME/{prj.path}.git"
prj.remote_mirrors.create({"url": ssh_url, "enabled": True})
-if __name__ == '__main__':
+if __name__ == "__main__":
main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]