This file contains 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
| #!/bin/python | |
| import sys | |
| import re | |
| import subprocess as sp | |
| if(len(sys.argv) < 2): | |
| sp.call('git clone') | |
| sys.exit() | |
| args = ' '.join(sys.argv[1:]) | |
| iterator = iter(sys.argv[1:]) | |
| for arg in iterator: | |
| if(re.match('^-', arg)): | |
| if(re.match('^(--(reference|origin|branch|upload-pack|template|config|depth|separate-git-dir)|-[obuc])', arg)): | |
| next(iterator) | |
| else: | |
| if(not re.match('^((ssh|git|http|https)://|git@)', arg)): | |
| args = args.replace(arg, '').strip() | |
| if(re.match('[a-zA-Z0-9]+/[a-zA-Z0-9]+', arg)): | |
| sp.call('git clone %s git@github.com:%s' % (args, arg)) | |
| else: | |
| # this seems overly complicated for the output | |
| p = sp.Popen('git config --get user.user', stdout = sp.PIPE) | |
| (user, e) = p.communicate() | |
| if(not len(user)): | |
| print 'Missing user.user in gitconfig' | |
| sys.exit() | |
| else: | |
| sp.call('git clone %s git@github.com:%s/%s' % (args, user.strip('\r\n'), arg)) | |
| else: | |
| sp.call('git clone %s' % (args)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment