Skip to content
Create a gist now

Instantly share code, notes, and snippets.

import sys, os, os.path
def ParseURL(url):
if url.startswith(""):
user, k, project = url.partition(':')[2].partition('/')
elif url.startswith(""):
user, k, project = url[len(""):].partition('/')
user = 'XXXX'
project = 'XXXX.git'
return [user, project[:-4]]
def GitFetch(user, project):
os.system("cd %s;git pull " % MainPath(user, project))
print "-- FETCH --"
print MainPath(user, project)
print Level1Path(user, project)
print Level2Path(user, project)
print Level3Path(user, project)
def GitClone(url, user, project):
lmain = MainPath(user, project)
except OSError, e:
print "git clone -o github %s %s" % (url, lmain)
os.system("git clone -o github %s %s" % (url, lmain))
l1 = Level1Path(user, project)
l2 = Level2Path(user, project)
l3 = Level3Path(user, project)
for l in [l1, l2, l3]:
except OSError, e:
os.symlink(lmain, l)
print "-- CLONE --"
print lmain
print l1
print l2
print l3
def MainPath(user, project):
return os.path.join(GITHUB_SRC_ROOT, user, project)
def Level1Path(user, project):
return os.path.join(GITHUB_SRC_ROOT, '1', project)
def Level2Path(user, project):
return os.path.join(GITHUB_SRC_ROOT, '2', user + "__" + project)
def Level3Path(user, project):
return os.path.join(GITHUB_SRC_ROOT, '3', project + "__" + user)
def main():
url = sys.argv[1]
if url [-1] == '/':
url = url[:-1]
if not url.endswith(".git"):
url = url + ".git"
user, project = ParseURL(url)
lmain = MainPath(user, project)
print lmain
if os.path.exists(lmain):
GitFetch(user, project)
GitClone(url, user, project)
if __name__ == '__main__':
# vim: ts=2 sts=2 ai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.