Index: ensure_dependencies.py |
diff --git a/ensure_dependencies.py b/ensure_dependencies.py |
index 9f2bcc7b7d8feec57b10e4c6d8b62989171ac8ff..1de24a2c1919e9b368748586c5bf1c1ae67c410b 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/(\S+))", remotes): |
Sebastian Noack
2015/05/06 14:45:12
I just realized that this regexp will find the bra
kzar
2015/05/06 15:11:13
Oh yea, also I realised if we check for the end of
Sebastian Noack
2015/05/06 15:17:56
Yeah, realized that as well, but slightly preferre
|
+ 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) |