Index: ensure_dependencies.py |
diff --git a/ensure_dependencies.py b/ensure_dependencies.py |
index 9f2bcc7b7d8feec57b10e4c6d8b62989171ac8ff..e4423013fa53a5f6ff8579da89c352915c646ac5 100755 |
--- a/ensure_dependencies.py |
+++ b/ensure_dependencies.py |
@@ -97,7 +97,20 @@ class Git(): |
return subprocess.check_output(command, cwd=repo).strip() |
def pull(self, repo): |
+ # Fetch tracked branches, new tags and the list of available remote branches |
subprocess.check_call(["git", "fetch", "--quiet", "--all", "--tags"], cwd=repo) |
+ # Next we need to ensure all remote branches are tracked |
+ newly_tracked = False |
+ remotes = subprocess.check_output(["git", "branch", "--remotes"], cwd=repo) |
+ for match in re.finditer(r"(?:^|\s)(origin/((?!HEAD(?:$|\s))\S+))", remotes): |
Wladimir Palant
2015/05/06 14:27:41
Is HEAD really worth excluding in the regexp? The
Sebastian Noack
2015/05/06 14:31:48
We actually had something like that before. I sugg
kzar
2015/05/06 14:37:31
Yea, I guess we don't need the check at all. Done.
|
+ remote, local = match.groups() |
+ with open(os.devnull, "wb") as devnull: |
+ if subprocess.call(["git", "branch", "--track", local, remote], |
+ cwd=repo, stdout=devnull, stderr=devnull) == 0: |
+ newly_tracked = True |
+ # Finally fetch any newly tracked remote branches |
+ if newly_tracked: |
+ subprocess.check_call(["git", "fetch", "--quiet", "origin"], cwd=repo) |
def update(self, repo, rev): |
subprocess.check_call(["git", "checkout", "--quiet", rev], cwd=repo) |