[sysadmin-bin] Support repositories using mainline as the default GitLab branch



commit 0a2230e913abda642c2136beead716dd0c4d0c9d
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Tue Oct 29 09:37:37 2019 +0100

    Support repositories using mainline as the default GitLab branch

 git/post-receive-mirror-github | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/git/post-receive-mirror-github b/git/post-receive-mirror-github
index 8f8423b..f7232fe 100755
--- a/git/post-receive-mirror-github
+++ b/git/post-receive-mirror-github
@@ -231,12 +231,15 @@ def main():
     if github_settings['homepage'] != doap_settings['homepage']:
         gh.update_github_repo(repo_name, 'homepage', doap_settings["homepage"])
 
-    refs = ["refs/heads/{}".format(branch) for branch in doap_settings['branches'] if branch not in 
("master", "mainline")]
+    if doap_settings['default_branch'] == 'mainline':
+        push_command = "git push --mirror git github com:{}/{}".format(org, github_repo_name)
+    else:
+        push_command_tpl = "git push --force git github com:{}/{} {}:mainline {}"
+        refs = ["refs/heads/{}".format(branch) for branch in doap_settings['branches'] if branch not in 
("master", "mainline")]
+        push_command = push_command_tpl.format(gh.organization, github_repo_name, 
doap_settings['default_branch'], " ".join(refs))
 
     github_repo_name = gh.normalize_name(repo_name)
-    push_command = "git push --force git github com:{}/{} {}:mainline {}"
-    command = push_command.format(gh.organization, github_repo_name, doap_settings['default_branch'], " 
".join(refs))
-    run_command(command)
+    run_command(push_command)
 
     if github_settings['default_branch'] != "mainline":
         gh.update_github_repo(repo_name, 'default_branch', "mainline")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]