コード例 #1
0
def clone_all_repos():

    # (get the bare repos)
    bare_repos_list = os.listdir(config.REPO_DIR)

    # (check for base-layout)
    if not config.BASE_REPO_NAME + ".git" in bare_repos_list:
        print('pds: {}.git repo not found, aborting.'.format(
            config.BASE_REPO_NAME))
        exit()

    # (check if already cloned)
    cloned_repos_list = os.listdir(config.GIT_WD)

    oldwd = os.getcwd()
    for bare_repo in bare_repos_list:
        repo_name = os.path.splitext(bare_repo)[0]

        if repo_name in cloned_repos_list:
            print('pds: repo "{}" already cloned, continuing...'.format(
                repo_name))
            continue

        # (clone)
        os.chdir(config.GIT_WD)
        git_cmd("clone", [os.path.join(config.REPO_DIR, bare_repo)])

    os.chdir(oldwd)
コード例 #2
0
def checkout_repo(repo):
    oldwd = os.getcwd()
    os.chdir(os.path.join(config.GIT_WD, repo.name))
    # (checkout)
    # --> evtl. make this nicer e.g. check if branch exists
    # (info print)
    print('pds: repo: "{}"'.format(repo.name))

    ret = git_cmd("checkout", [repo.branch.name])
    if ret == 0:
        # (add to return list)
        has_branch = True
    else:
        has_branch = False
        print('pds: repo "{}" has no branch "{}"'.format(
            repo.name, repo.branch.name))

    # (update the branch)
    # --> evtl. also make this nicer e.g. check if up-to-date
    # (info print)
    #print("pds: update repo: ", repo)
    git_cmd("pull")
    os.chdir(oldwd)

    return has_branch
コード例 #3
0
ファイル: git_processing.py プロジェクト: rebootl/pds
def clone_all_repos():

    # (get the bare repos)
    bare_repos_list=os.listdir(config.REPO_DIR)

    # (check for base-layout)
    if not config.BASE_REPO_NAME+".git" in bare_repos_list:
        print('pds: {}.git repo not found, aborting.'.format(config.BASE_REPO_NAME))
        exit()

    # (check if already cloned)
    cloned_repos_list=os.listdir(config.GIT_WD)

    oldwd=os.getcwd()
    for bare_repo in bare_repos_list:
        repo_name=os.path.splitext(bare_repo)[0]

        if repo_name in cloned_repos_list:
            print('pds: repo "{}" already cloned, continuing...'.format(repo_name))
            continue

        # (clone)
        os.chdir(config.GIT_WD)
        git_cmd("clone", [ os.path.join(config.REPO_DIR, bare_repo) ])

    os.chdir(oldwd)
コード例 #4
0
ファイル: git_processing.py プロジェクト: rebootl/pds
def checkout_repo(repo):
    oldwd = os.getcwd()
    os.chdir( os.path.join(config.GIT_WD, repo.name) )
    # (checkout)
    # --> evtl. make this nicer e.g. check if branch exists
    # (info print)
    print('pds: repo: "{}"'.format(repo.name))

    ret = git_cmd("checkout", [ repo.branch.name ])
    if ret == 0:
        # (add to return list)
        has_branch = True
    else:
        has_branch = False
        print('pds: repo "{}" has no branch "{}"'.format( repo.name,
                                                          repo.branch.name ))

    # (update the branch)
    # --> evtl. also make this nicer e.g. check if up-to-date
    # (info print)
    #print("pds: update repo: ", repo)
    git_cmd("pull")
    os.chdir(oldwd)

    return has_branch
コード例 #5
0
ファイル: gitpublish-new-repo.py プロジェクト: rebootl/pds
def new_repo(repo_name_in):

    repo_name = repo_name_in + ".git"
    repo_path = os.path.join(config.REPO_DIR, repo_name)

    git_opts = ["--bare", repo_path]
    git_cmd("init", git_opts)

    # create hooks
    print("generating hooks:")

    hooks = ['post-receive', 'update']
    hooks_desc = [
        'initiate pds update, after a push',
        'cleanup the git-wd, when a branch was deleted'
    ]
    hooks_content = [
        '''#!/usr/bin/bash
#
# pds hook
# - initiate pds update, after a push
#
# hooks/post-receive
unset GIT_DIR
{}
'''.format(PDS_EXPATH), '''#!/usr/bin/bash
#
# pds hook
# - cleanup the git-wd, when a branch was deleted
#
# hooks/update
# based on hooks/update.sample

# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"

# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" != "$zero" ]; then
    exit 0
fi

REPO_NAME_EXT=$(basename "$PWD")
REPO_NAME="${{REPO_NAME_EXT%.*}}"
echo "hook-update: a branch was deleted on $REPO_NAME"

GIT_WD="{}"

CLEANUP="$GIT_WD/$REPO_NAME"
echo "hook-update: removing git-wd: $CLEANUP"
rm -rf "$CLEANUP"
'''.format(config.GIT_WD)
    ]

    for i, hook in enumerate(hooks):
        print("- hooks/{} ({})".format(hook, hooks_desc[i]))
        # write hook
        hook_path = os.path.join(repo_path, "hooks", hook)

        write_out(hooks_content[i], hook_path)

        # make executable
        os.chmod(hook_path, 0o755)

    print("\nuse: git remote add <name> <url>")
    print("to add it to your local repo")
コード例 #6
0
ファイル: gitpublish-new-repo.py プロジェクト: rebootl/pds
def new_repo(repo_name_in):

    repo_name = repo_name_in + ".git"
    repo_path = os.path.join(config.REPO_DIR, repo_name)

    git_opts = [ "--bare", repo_path ]
    git_cmd( "init", git_opts )

    # create hooks
    print("generating hooks:")

    hooks = [ 'post-receive', 'update' ]
    hooks_desc = [ 'initiate pds update, after a push',
                   'cleanup the git-wd, when a branch was deleted' ]
    hooks_content = [ '''#!/usr/bin/bash
#
# pds hook
# - initiate pds update, after a push
#
# hooks/post-receive
unset GIT_DIR
{}
'''.format(PDS_EXPATH),

'''#!/usr/bin/bash
#
# pds hook
# - cleanup the git-wd, when a branch was deleted
#
# hooks/update
# based on hooks/update.sample

# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"

# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" != "$zero" ]; then
    exit 0
fi

REPO_NAME_EXT=$(basename "$PWD")
REPO_NAME="${{REPO_NAME_EXT%.*}}"
echo "hook-update: a branch was deleted on $REPO_NAME"

GIT_WD="{}"

CLEANUP="$GIT_WD/$REPO_NAME"
echo "hook-update: removing git-wd: $CLEANUP"
rm -rf "$CLEANUP"
'''.format(config.GIT_WD) ]

    for i, hook in enumerate(hooks):
        print("- hooks/{} ({})".format(hook, hooks_desc[i]))
        # write hook
        hook_path = os.path.join(repo_path, "hooks", hook)

        write_out(hooks_content[i], hook_path)

        # make executable
        os.chmod(hook_path, 0o755)

    print("\nuse: git remote add <name> <url>")
    print("to add it to your local repo")