Skip to content

Commit

Permalink
Parse owner and repository in a url safe way
Browse files Browse the repository at this point in the history
This allows us to retain the '/' separation of URL pieces in any gitlab
urls that have been stored in the object. This change also lays the
groundwork for a fix in the -elk repository to allow multiple nested
gitlab group layers in gitlab URLs.

See also: chaoss/grimoirelab-elk#946

Signed-off-by: Raimund Hook <[email protected]>
  • Loading branch information
StingRayZA committed Nov 3, 2020
1 parent b1b90b8 commit 5fa96f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions perceval/backends/core/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ def merge(self, merge_id):
"""Get the merge full data"""

path = urijoin(self.base_url,
self.RPROJECTS, self.owner + '%2F' + self.repository,
self.RPROJECTS, urllib.parse.quote(
self.owner + '/' + self.repository, safe=''),
self.RMERGES, merge_id)

response = self.fetch(path)
Expand All @@ -578,7 +579,8 @@ def merge_version(self, merge_id, version_id):
"""Get merge version detail"""

path = urijoin(self.base_url,
self.RPROJECTS, self.owner + '%2F' + self.repository,
self.RPROJECTS, urllib.parse.quote(
self.owner + '/' + self.repository, safe=''),
self.RMERGES, merge_id, self.RVERSIONS, version_id)

response = self.fetch(path)
Expand Down Expand Up @@ -663,7 +665,9 @@ def fetch_items(self, path, payload):

page = 0 # current page
last_page = None # last page
url_next = urijoin(self.base_url, self.RPROJECTS, self.owner + '%2F' + self.repository, path)
url_next = urijoin(
self.base_url, self.RPROJECTS, urllib.parse.quote(
self.owner + '/' + self.repository, safe=''), path)

logger.debug("Get GitLab paginated items from " + url_next)

Expand Down Expand Up @@ -735,7 +739,8 @@ def _set_extra_headers(self):
def _init_rate_limit(self):
"""Initialize rate limit information"""

url = urijoin(self.base_url, 'projects', self.owner + '%2F' + self.repository)
url = urijoin(self.base_url, 'projects', urllib.parse.quote(
self.owner + '/' + self.repository, safe=''))
try:
response = super().fetch(url)
self.update_rate_limit(response)
Expand Down

0 comments on commit 5fa96f1

Please sign in to comment.