mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
Add logic for transforming gist repository urls to ssh
This commit is contained in:
@@ -419,7 +419,13 @@ def get_github_host(args):
|
|||||||
|
|
||||||
def get_github_repo_url(args, repository):
|
def get_github_repo_url(args, repository):
|
||||||
if repository.get('is_gist'):
|
if repository.get('is_gist'):
|
||||||
return repository['git_pull_url']
|
if args.prefer_ssh:
|
||||||
|
# The git_pull_url value is always https for gists, so we need to transform it to ssh form
|
||||||
|
repo_url = re.sub('^https?:\/\/(.+)\/(.+)\.git$', r'git@\1:\2.git', repository['git_pull_url'])
|
||||||
|
repo_url = re.sub('^git@gist\.', 'git@', repo_url) # strip gist subdomain for better hostkey compatibility
|
||||||
|
else:
|
||||||
|
repo_url = repository['git_pull_url']
|
||||||
|
return repo_url
|
||||||
|
|
||||||
if args.prefer_ssh:
|
if args.prefer_ssh:
|
||||||
return repository['ssh_url']
|
return repository['ssh_url']
|
||||||
|
|||||||
Reference in New Issue
Block a user