[sysadmin-bin] Fetch required variables before pushing to GitHub
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Fetch required variables before pushing to GitHub
- Date: Tue, 15 Oct 2019 11:08:08 +0000 (UTC)
commit 06d1d561268dd3c1ad3642b41e8675f8c2336474
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Tue Oct 15 13:07:35 2019 +0200
Fetch required variables before pushing to GitHub
git/post-receive-mirror-github | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/git/post-receive-mirror-github b/git/post-receive-mirror-github
index ffa79a6..54be0f3 100755
--- a/git/post-receive-mirror-github
+++ b/git/post-receive-mirror-github
@@ -115,7 +115,7 @@ class GitHub:
default_branch = rq.json()['default_branch']
rq = requests.get("{}/branches".format(api_url), auth=(self.user, self.pw))
- branches = {branch['name'] for branch in rg.json()}
+ branches = {branch['name'] for branch in rq.json()}
if rq.status_code != 200:
raise Exception("There was an error attempting to fetch branches of the repo %s in
github:\n\nStatus: %d\nText:\n%s" % (name, rq.status_code, rq.text))
@@ -184,6 +184,12 @@ def main():
sys.exit(1)
settings = get_repo_settings(repo_name)
+ repo_exists = gh.check_if_repo_exists(repo_name)
+
+ if repo_exists:
+ description, homepage, default_branch, branches = gh.fetch_github_repo(github_name)
+ else:
+ gh.create_github_repo(settings["name"], settings["description"], settings["homepage"])
for organization in [gh.organization] + ADDITIONAL_ORGANIZATIONS.get(repo_name, []):
try:
@@ -199,12 +205,7 @@ def main():
err = open(err.name, "r")
raise Exception("Error trying to push repo %s/%s\nSTDOUT:\n%s\nSTDERR\n%s" % (organization,
repo_name, out.read(), err.read()))
- 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, default_branch, branches = gh.fetch_github_repo(github_name)
-
+ if repo_exists:
if description != settings["description"]:
gh.update_github_repo(github_name, 'description', settings["description"])
@@ -213,6 +214,8 @@ def main():
if default_branch != 'mainline':
gh.update_github_repo(github_name, 'default_branch', 'mainline')
+ else:
+ gh.update_github_repo(github_name, 'default_branch', settings["default_branch"])
if __name__ == "__main__":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]