Skip to content

Instantly share code, notes, and snippets.

@elmariofredo
Created November 29, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmariofredo/fb10ec8d5dbe41dbabfee74d144c5d2e to your computer and use it in GitHub Desktop.
Save elmariofredo/fb10ec8d5dbe41dbabfee74d144c5d2e to your computer and use it in GitHub Desktop.
Cloning github/gitlab/copanyhub in consistent way
#!/usr/bin/env python
import sys, subprocess, os
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
rawRepoUrl = sys.argv[1]
parsedRepoUrl = urlparse(rawRepoUrl)
repoSecondLevelDomain = parsedRepoUrl.netloc.split(':')[0].split('.')[-2].upper()
projectPath = parsedRepoUrl.path
localCheckoutPath = os.path.expanduser( '~/' + repoSecondLevelDomain + projectPath )
print 'Syncing the internet to:', localCheckoutPath
subprocess.call(['git', 'clone', rawRepoUrl, localCheckoutPath])
print 'Cink!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment