From 11ddf04bc580215396f61c60ee79242dc4e2371a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 27 Oct 2015 11:28:21 -0400 Subject: [PATCH] gitlab: handle projects with disable MRs or issues Though the upstream API should just return an empty list. --- bugwarrior/services/gitlab.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bugwarrior/services/gitlab.py b/bugwarrior/services/gitlab.py index be364eba9..eef1741b4 100644 --- a/bugwarrior/services/gitlab.py +++ b/bugwarrior/services/gitlab.py @@ -321,7 +321,12 @@ def _fetch_paged(self, tmpl): def get_repo_issues(self, rid): tmpl = '{scheme}://{host}/api/v3/projects/%d/issues' % rid issues = {} - for issue in self._fetch_paged(tmpl): + try: + repo_issues = self._fetch_paged(tmpl) + except: + # Projects may have issues disabled. + return [] + for issue in repo_issues: if issue['state'] != 'opened': continue issues[issue['id']] = (rid, issue) @@ -330,7 +335,12 @@ def get_repo_issues(self, rid): def get_repo_merge_requests(self, rid): tmpl = '{scheme}://{host}/api/v3/projects/%d/merge_requests' % rid issues = {} - for issue in self._fetch_paged(tmpl): + try: + repo_merge_requests = self._fetch_paged(tmpl) + except: + # Projects may have merge requests disabled. + return [] + for issue in repo_merge_requests: if issue['state'] != 'opened': continue issues[issue['id']] = (rid, issue)