diff --git a/bugwarrior/docs/services/gitlab.rst b/bugwarrior/docs/services/gitlab.rst index 94537a6af..653bd154e 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 513094f78..709af4f3d 100644 --- a/bugwarrior/services/gitlab.py +++ b/bugwarrior/services/gitlab.py @@ -198,6 +198,11 @@ def __init__(self, *args, **kw): ) self.auth = (host, token) + if self.config_get_default('use_https', default=True, to_type=asbool): + self.scheme = 'https' + else: + self.scheme = 'http' + self.exclude_repos = [] if self.config_get_default('exclude_repos', None): self.exclude_repos = [ @@ -252,7 +257,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): @@ -266,7 +271,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(scheme=self.scheme, host=self.auth[0]) headers = {'PRIVATE-TOKEN': self.auth[1]} response = requests.get(url, headers=headers, **kwargs) @@ -312,7 +317,7 @@ 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): if issue['state'] != 'opened': @@ -321,7 +326,7 @@ def get_repo_issues(self, rid): 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): if issue['state'] != 'opened': @@ -330,7 +335,7 @@ def get_repo_merge_requests(self, rid): 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)