[sysadmin-bin: 1/2] post-receive-mirror-github: Set default branch
- From: Andrea Veri <averi src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin: 1/2] post-receive-mirror-github: Set default branch
- Date: Fri, 26 Apr 2019 08:36:41 +0000 (UTC)
commit 26b64811b0cd1f5aeee663b980c091503a72d00e
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Fri Apr 26 08:36:30 2019 +0000
post-receive-mirror-github: Set default branch
fixes #132
git/post-receive-mirror-github | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/git/post-receive-mirror-github b/git/post-receive-mirror-github
index 2dbb181..b27ab46 100755
--- a/git/post-receive-mirror-github
+++ b/git/post-receive-mirror-github
@@ -108,9 +108,10 @@ class GitHub:
description = rq.json()['description']
homepage = rq.json()['homepage']
+ default_branch = rq.json()['default_branch']
if rq.status_code == 200:
- return description, homepage
+ return description, homepage, default_branch
raise Exception("There was an error attempting to fetch the repo %s in github:\n\nStatus:
%d\nText:\n%s" % (name, rq.status_code, rq.text))
@@ -123,6 +124,7 @@ class GitHub:
return name
+
def get_repo_name():
repo_name = os.getcwd().split("/")[-1]
if repo_name == ".git":
@@ -158,9 +160,13 @@ def get_repo_settings(repo_name):
homepage = homepage.get(resource) if homepage != None else 'https://gitlab.gnome.org/GNOME'
homepage = homepage if homepage != None else 'https://gitlab.gnome.org/GNOME'
- return { "homepage": homepage.encode('utf-8').decode('utf-8'),
- "name": repo_name.encode('utf-8').decode('utf-8'),
- "description": desc.encode('utf-8').decode('utf-8')}
+ return {
+ "homepage": homepage.encode("utf-8").decode("utf-8"),
+ "name": repo_name.encode("utf-8").decode("utf-8"),
+ "description": desc.encode("utf-8").decode("utf-8"),
+ "default_branch": branch_name.encode("utf-8").decode("utf-8"),
+ }
+
def main():
gh = GitHub(ORGANIZATION)
@@ -174,14 +180,18 @@ def main():
if not gh.check_if_repo_exists(repo_name):
gh.create_github_repo(settings["name"], settings["description"], settings["homepage"])
+ gh.update_github_repo(github_name, 'default_branch', settings["default_branch"])
else:
- description, homepage = gh.fetch_github_repo(github_name)
+ description, homepage, default_branch = gh.fetch_github_repo(github_name)
if description != settings["description"]:
gh.update_github_repo(github_name, 'description', settings["description"])
if homepage != settings["homepage"]:
gh.update_github_repo(github_name, 'homepage', settings["homepage"])
+
+ if default_branch != settings["default_branch"]:
+ gh.update_github_repo(github_name, 'default_branch', settings["default_branch"])
for organization in [gh.organization] + ADDITIONAL_ORGANIZATIONS.get(repo_name, []):
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]