From 616a389d75900b407ad813739c8ba0eb27e07fff Mon Sep 17 00:00:00 2001 From: Zack Piper Date: Sat, 1 Aug 2015 19:47:55 +0000 Subject: [PATCH 1/2] Include an option to disable HTTPS for GitLab. --- bugwarrior/services/gitlab.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bugwarrior/services/gitlab.py b/bugwarrior/services/gitlab.py index 6bb34c6fa..8d34fed67 100644 --- a/bugwarrior/services/gitlab.py +++ b/bugwarrior/services/gitlab.py @@ -170,6 +170,11 @@ def __init__(self, *args, **kw): ) self.auth = (host, token) + if self.config_get('https') == 'https': + self.https = 'https' + else: + self.https = 'http' + self.exclude_repos = [] if self.config_get_default('exclude_repos', None): self.exclude_repos = [ @@ -224,7 +229,7 @@ def filter_repos(self, repo): return True def _get_notes(self, rid, issue_type, issueid): - tmpl = 'https://{host}/api/v3/projects/%d/%s/%d/notes' % (rid, issue_type, issueid) + tmpl = '{https}://{host}/api/v3/projects/%d/%s/%d/notes' % (rid, issue_type, issueid) return self._fetch_paged(tmpl) def annotations(self, repo, url, issue_type, issue, issue_obj): @@ -238,7 +243,7 @@ def annotations(self, repo, url, issue_type, issue, issue_obj): ) def _fetch(self, tmpl, **kwargs): - url = tmpl.format(host=self.auth[0]) + url = tmpl.format(https=self.https, host=self.auth[0]) headers = {'PRIVATE-TOKEN': self.auth[1]} response = requests.get(url, headers=headers, **kwargs) @@ -270,21 +275,21 @@ def _fetch_paged(self, tmpl): return full def get_repo_issues(self, rid): - tmpl = 'https://{host}/api/v3/projects/%d/issues' % rid + tmpl = '{https}://{host}/api/v3/projects/%d/issues' % rid issues = {} for issue in self._fetch_paged(tmpl): issues[issue['id']] = (rid, issue) return issues def get_repo_merge_requests(self, rid): - tmpl = 'https://{host}/api/v3/projects/%d/merge_requests' % rid + tmpl = '{https}://{host}/api/v3/projects/%d/merge_requests' % rid issues = {} for issue in self._fetch_paged(tmpl): issues[issue['id']] = (rid, issue) return issues def issues(self): - tmpl = 'https://{host}/api/v3/projects' + tmpl = '{https}://{host}/api/v3/projects' all_repos = self._fetch_paged(tmpl) repos = filter(self.filter_repos, all_repos) From 5d95424f6f0c09bf0e54683ac1fa0c52ca2a3d11 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 10 Sep 2015 13:44:12 -0400 Subject: [PATCH 2/2] Document use_https for gitlab. --- bugwarrior/docs/services/gitlab.rst | 8 ++++++++ bugwarrior/services/gitlab.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bugwarrior/docs/services/gitlab.rst b/bugwarrior/docs/services/gitlab.rst index dcc04b264..1231136a5 100644 --- a/bugwarrior/docs/services/gitlab.rst +++ b/bugwarrior/docs/services/gitlab.rst @@ -82,6 +82,14 @@ by adding the following configuration option:: gitlab.filter_merge_requests = True +Use HTTP +++++++++ + +If your Gitlab instance is only available over HTTP, set:: + + gitlab.use_https = False + + Provided UDA Fields ------------------- diff --git a/bugwarrior/services/gitlab.py b/bugwarrior/services/gitlab.py index 8d34fed67..95f651c18 100644 --- a/bugwarrior/services/gitlab.py +++ b/bugwarrior/services/gitlab.py @@ -170,10 +170,10 @@ def __init__(self, *args, **kw): ) self.auth = (host, token) - if self.config_get('https') == 'https': - self.https = 'https' + if self.config_get_default('use_https', default=True, to_type=asbool): + self.scheme = 'https' else: - self.https = 'http' + self.scheme = 'http' self.exclude_repos = [] if self.config_get_default('exclude_repos', None): @@ -229,7 +229,7 @@ def filter_repos(self, repo): return True def _get_notes(self, rid, issue_type, issueid): - tmpl = '{https}://{host}/api/v3/projects/%d/%s/%d/notes' % (rid, issue_type, issueid) + tmpl = '{scheme}://{host}/api/v3/projects/%d/%s/%d/notes' % (rid, issue_type, issueid) return self._fetch_paged(tmpl) def annotations(self, repo, url, issue_type, issue, issue_obj): @@ -243,7 +243,7 @@ def annotations(self, repo, url, issue_type, issue, issue_obj): ) def _fetch(self, tmpl, **kwargs): - url = tmpl.format(https=self.https, host=self.auth[0]) + url = tmpl.format(scheme=self.scheme, host=self.auth[0]) headers = {'PRIVATE-TOKEN': self.auth[1]} response = requests.get(url, headers=headers, **kwargs) @@ -275,21 +275,21 @@ def _fetch_paged(self, tmpl): return full def get_repo_issues(self, rid): - tmpl = '{https}://{host}/api/v3/projects/%d/issues' % rid + tmpl = '{scheme}://{host}/api/v3/projects/%d/issues' % rid issues = {} for issue in self._fetch_paged(tmpl): issues[issue['id']] = (rid, issue) return issues def get_repo_merge_requests(self, rid): - tmpl = '{https}://{host}/api/v3/projects/%d/merge_requests' % rid + tmpl = '{scheme}://{host}/api/v3/projects/%d/merge_requests' % rid issues = {} for issue in self._fetch_paged(tmpl): issues[issue['id']] = (rid, issue) return issues def issues(self): - tmpl = '{https}://{host}/api/v3/projects' + tmpl = '{scheme}://{host}/api/v3/projects' all_repos = self._fetch_paged(tmpl) repos = filter(self.filter_repos, all_repos)