Exemple #1
0
def update_local_branches_pkg(pkg):
    fs.goto(pkg)
    lbranches = []
    rbranches = []
    branches = cmd('git branch -a',output=True).split('\n')

    prefix='upstream-svn/tags/'

    for branch in branches:
        branch = branch.strip()
        if not branch: continue
        if branch[0] == '*': branch = branch[2:]
        if branch[0:len(prefix)] == prefix:
            rbranches.append(branch)
        elif '/' not in branch:
            lbranches.append(branch)
        continue

    for rbranch in rbranches:
        tag = rbranch[len(prefix):]
        if tag in lbranches: continue
        cmd('git checkout -t -b %s %s'%(tag,rbranch))

    cmd('git checkout upstream-svn-trunk')
    fs.goback()
Exemple #2
0
def init_pkg(url,pkg):
    log.info('Initializing %s'%pkg)

    if not os.path.exists(pkg): os.mkdir(pkg)
    fs.goto(pkg)

    if not os.path.exists('.git'): 
        url = 'https://svnweb.cern.ch/guest/gaudi/packages/%s'%pkg
        cmd('git-svn init -s --prefix=upstream-svn/ %s'%url)
        cmd('git-svn fetch')

    fs.goback()
    if not os.path.exists('.git'): cmd('git init')

    def need_add():
        if os.path.exists('.gitmodules'):
            fp = open(".gitmodules")
            lines = map(lambda x: x.strip(), fp.readlines())
            if '[submodule "%s"]'%pkg in lines: return False
        return True
    if need_add():
        cmd('git submodule add %s/%s %s'%(url,pkg,pkg))
        
    fp = open('.git/config')
    lines = map(lambda x: x.strip(), fp.readlines())
    if not '[submodule "%s"]'%pkg in lines:
        cmd('git submodule init %s'%pkg)


    cmd('git add %s'%pkg)

    return