From: Zack Cerza Date: Fri, 4 Mar 2016 16:23:31 +0000 (-0700) Subject: repo_utils: Call git set remote-url X-Git-Tag: 1.1.0~660^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4d8b1d7cb899c3d71daaba33be36ac4aff9b70c;p=teuthology.git repo_utils: Call git set remote-url This will cause git repos on-disk to be updated to point at the correct remote based on config.ceph_git_base_url Signed-off-by: Zack Cerza --- diff --git a/teuthology/repo_utils.py b/teuthology/repo_utils.py index fe228a99..3c9b0085 100644 --- a/teuthology/repo_utils.py +++ b/teuthology/repo_utils.py @@ -30,6 +30,7 @@ def enforce_repo_state(repo_url, dest_path, branch, remove_on_error=True): clone_repo(repo_url, dest_path, branch) elif time.time() - os.stat('/etc/passwd').st_mtime > 60: # only do this at most once per minute + set_remote(dest_path, repo_url) fetch(dest_path) out = subprocess.check_output(('touch', dest_path)) if out: @@ -79,6 +80,26 @@ def clone_repo(repo_url, dest_path, branch): raise GitError("git clone failed!") +def set_remote(repo_path, repo_url): + """ + Call "git remote set-url origin " + + :param repo_url: The full URL to the repo (not including the branch) + :param repo_path: The full path to the repository + :raises: GitError if the operation fails + """ + log.debug("Setting repo remote to %s", repo_url) + proc = subprocess.Popen( + ('git', 'remote', 'set-url', 'origin', repo_url), + cwd=repo_path, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + if proc.wait() != 0: + out = proc.stdout.read() + log.error(out) + raise GitError("git remote set-url failed!") + + def fetch(repo_path): """ Call "git fetch -p origin"