Skip to content

Commit

Permalink
Document use_https for gitlab.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Sep 10, 2015
1 parent 616a389 commit 5d95424
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 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
16 changes: 8 additions & 8 deletions bugwarrior/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 5d95424

Please sign in to comment.