Skip to content

Commit

Permalink
Fixed issue where only master branch remotes were supported
Browse files Browse the repository at this point in the history
  • Loading branch information
fireundubh committed Jan 11, 2020
1 parent 36f15e3 commit 71b4b39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyro/PapyrusProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def _get_remote_path(self, node: etree.ElementBase) -> str:
url_path = os.sep.join(url_path_parts)
elif parsed_url.netloc == 'github.com':
url_path_parts = parsed_url.path.split('/')[1:]
url_path_parts.pop(3) # pop 'master'
url_path_parts.pop(3) # pop 'master' (or any other branch)
url_path_parts.pop(2) # pop 'tree'
url_path = os.sep.join(url_path_parts)
else:
Expand Down
12 changes: 9 additions & 3 deletions pyro/Remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ def get_contents(self, url: str, output_path: str) -> Generator:
if parsed_url.netloc == 'api.github.com':
request_url = url
_, owner, repo = url_path.split('/')[:3]
else:
url_path = url_path.replace('tree/master', 'contents')
elif parsed_url.netloc == 'github.com':
url_path_parts = parsed_url.path.split('/')[1:]
url_path_parts.pop(3) # pop 'master' (or any other branch)
url_path_parts.pop(2) # pop 'tree'
url_path_parts.insert(2, 'contents')
url_path = '/'.join(url_path_parts)
request_url = f'https://api.github.com/repos/{url_path}'
owner, repo = url_path.split('/')[:2]
owner, repo = url_path_parts[0], url_path_parts[1]
else:
raise NotImplementedError

request = Request(request_url)
request.add_header('Authorization', f'token {self.access_token}')
Expand Down

0 comments on commit 71b4b39

Please sign in to comment.