[sysadmin-bin] Guard setting protected branches with try/except due to wobbly API
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] Guard setting protected branches with try/except due to wobbly API
- Date: Fri, 27 Sep 2019 15:03:48 +0000 (UTC)
commit 9459e85e4a4dd438cd53f275f901f7599b8cdaa1
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date: Fri Sep 27 17:03:17 2019 +0200
Guard setting protected branches with try/except due to wobbly API
gitlab/gitlab-operations.py | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/gitlab/gitlab-operations.py b/gitlab/gitlab-operations.py
index b15dab8..0c4715e 100755
--- a/gitlab/gitlab-operations.py
+++ b/gitlab/gitlab-operations.py
@@ -99,15 +99,18 @@ for project in projects:
if not default_branch:
default_branch = 'master'
- proj = gl.projects.get(project.id, lazy=True)
- branches = [branch.name for branch in proj.branches.list()]
- stable_branches_regex = re.compile(r'gnome-\d-\d\d')
- stable_branches = set(filter(stable_branches_regex.match, branches))
- protected_branches = {branch.name for branch in proj.protectedbranches.list()}
-
- for branch_name in (stable_branches - protected_branches):
- branch = proj.branches.get(branch_name, lazy=True)
- branch.protect(developers_can_push=True, developers_can_merge=True)
+ try:
+ proj = gl.projects.get(project.id, lazy=True)
+ branches = [branch.name for branch in proj.branches.list()]
+ stable_branches_regex = re.compile(r'gnome-\d-\d\d')
+ stable_branches = set(filter(stable_branches_regex.match, branches))
+ protected_branches = {branch.name for branch in proj.protectedbranches.list()}
+
+ for branch_name in (stable_branches - protected_branches):
+ branch = proj.branches.get(branch_name, lazy=True)
+ branch.protect(developers_can_push=True, developers_can_merge=True)
+ except:
+ print 'Skip setting protected branches for %s due to API error' % project_name
try:
nodes = semi_rdf.read_rdf(doap_url % (project_name, default_branch, project_name))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]