Created
November 29, 2017 23:49
-
-
Save devopsmariocom/fb10ec8d5dbe41dbabfee74d144c5d2e to your computer and use it in GitHub Desktop.
Cloning github/gitlab/copanyhub in consistent way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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