Skip to content

Commit

Permalink
Merge branch 'https-or-http' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Sep 10, 2015
2 parents f84eca7 + 5d95424 commit f3b63ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions bugwarrior/docs/services/gitlab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------

Expand Down
15 changes: 10 additions & 5 deletions bugwarrior/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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':
Expand All @@ -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':
Expand All @@ -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)

Expand Down

0 comments on commit f3b63ba

Please sign in to comment.