Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ensure_dependencies.py

Issue 6068640302497792: Issue 2311 - Track remote Git branches when required (Closed)
Patch Set: Make Git.pull track all remote branches Created May 6, 2015, 11:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ensure_dependencies.py
diff --git a/ensure_dependencies.py b/ensure_dependencies.py
index b6557d051f6661645dea95edfde280ea288f7533..70130b5d97e7327d07128596f3c2e7d50771dc1e 100755
--- a/ensure_dependencies.py
+++ b/ensure_dependencies.py
@@ -97,6 +97,17 @@ class Git():
return subprocess.check_output(command, cwd=repo).strip()
def pull(self, repo):
+ # First perform a fetch so we have a list of remote branch names
+ subprocess.check_call(["git", "fetch", "--quiet"], cwd=repo)
+ # Next we need to ensure all remote branches are tracked
+ remotes = subprocess.check_output(["git", "branch", "--remotes"], cwd=repo)
+ for match in re.finditer(r"origin/(\S+)", remotes):
+ remote, local = match.group(0), match.group(1)
+ if local not in ["HEAD", "master"]:
+ with open(os.devnull, "w") as devnull:
+ subprocess.call(["git", "branch", "--track", local, remote],
+ cwd=repo, stdout=devnull, stderr=devnull)
+ # Finally we need to actually fetch all the remote branches and tags
subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=repo)
def update(self, repo, rev):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld