Exemple #1
0
def clone_repo(git):
    # TODO(axw) only rewrite if server retports
    # changes to the relation settings.
    hostname = git.get_remote('hostname')
    write_git_ssh(hostname, git.ssh_host_keys())

    url = git.url()
    status_set('waiting', 'Cloning {}'.format(url))
    # TODO(axw) separate paths for .git and contents
    path = git_repo_path()
    dotgit = os.path.join(path, '.git')
    if os.path.exists(dotgit):
        shutil.rmtree(dotgit)
    git_exec(git, 'clone', url, path)

    # set the initial commit in local state
    commit = git_exec(git, 'rev-parse', cwd=path)
    if commit:
        git.set_commit(commit)
    status_set('active', '')
    git.set_local('repo-path', path)
    set_state('git.repo-available')
Exemple #2
0
def commit_changed(git):
    sha = git.get_remote('git-commit')
    path = git_repo_path()
    git_exec(git, 'fetch', 'origin', cwd=path)
    git_exec(git, 'checkout', sha, cwd=path)
    git.set_commit(sha)