Skip to content

Commit e53f8d4

Browse files
authored
Merge pull request josegonzalez#153 from 0x6d617474/gist_ssh
Add logic for transforming gist repository urls to ssh
2 parents 1312863 + 356f5f6 commit e53f8d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

github_backup/github_backup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,13 @@ def get_github_host(args):
419419

420420
def get_github_repo_url(args, repository):
421421
if repository.get('is_gist'):
422-
return repository['git_pull_url']
422+
if args.prefer_ssh:
423+
# The git_pull_url value is always https for gists, so we need to transform it to ssh form
424+
repo_url = re.sub('^https?:\/\/(.+)\/(.+)\.git$', r'git@\1:\2.git', repository['git_pull_url'])
425+
repo_url = re.sub('^git@gist\.', 'git@', repo_url) # strip gist subdomain for better hostkey compatibility
426+
else:
427+
repo_url = repository['git_pull_url']
428+
return repo_url
423429

424430
if args.prefer_ssh:
425431
return repository['ssh_url']

0 commit comments

Comments
 (0)