diff options
author | Brian Coca <bcoca@ansible.com> | 2015-09-04 12:46:51 -0400 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2015-09-04 12:46:51 -0400 |
commit | 57c0b86db4af3f1de54509cecef5054f77466ae1 (patch) | |
tree | 598ddbba982be8529301a24e4d327963e6f0641a /source_control/git.py | |
parent | 2520627fe7d487a08e077a01bb1251f3757f0515 (diff) | |
parent | d7efb2635c003bdb6dcb8e1321f8c94434f720cf (diff) | |
download | ansible-modules-core-57c0b86db4af3f1de54509cecef5054f77466ae1.tar.gz |
Merge pull request #721 from jinowolski/devel
update git remote url before ls-remote
Diffstat (limited to 'source_control/git.py')
-rw-r--r-- | source_control/git.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source_control/git.py b/source_control/git.py index bc35c97d..4b162039 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -491,10 +491,20 @@ def get_head_branch(git_path, module, dest, remote, bare=False): f.close() return branch -def fetch(git_path, module, repo, dest, version, remote, bare, refspec): +def set_remote_url(git_path, module, repo, dest, remote): ''' updates repo from remote sources ''' commands = [("set a new url %s for %s" % (repo, remote), [git_path, 'remote', 'set-url', remote, repo])] + for (label,command) in commands: + (rc,out,err) = module.run_command(command, cwd=dest) + if rc != 0: + module.fail_json(msg="Failed to %s: %s %s" % (label, out, err)) + +def fetch(git_path, module, repo, dest, version, remote, bare, refspec): + ''' updates repo from remote sources ''' + set_remote_url(git_path, module, repo, dest, remote) + commands = [] + fetch_str = 'download remote objects and refs' if bare: @@ -741,6 +751,7 @@ def main(): if not module.check_mode: reset(git_path, module, dest) # exit if already at desired sha version + set_remote_url(git_path, module, repo, dest, remote) remote_head = get_remote_head(git_path, module, dest, version, remote, bare) if before == remote_head: if local_mods: |