[Downloader] Respect current branch when updating (#675)

This commit is contained in:
Caleb Johnson 2017-04-19 15:25:12 -05:00 committed by Twentysix
parent 719088d438
commit bb4a036573

View File

@ -588,11 +588,15 @@ class Downloader:
self.populate_list(name) self.populate_list(name)
return name, REPO_CLONE, None return name, REPO_CLONE, None
else: else:
rpcmd = ["git", "-C", dd + name, "rev-parse", "HEAD"] rpbcmd = ["git", "-C", dd + name, "rev-parse", "--abbrev-ref", "HEAD"]
p = run(rpbcmd, stdout=PIPE)
branch = p.stdout.decode().strip()
rpcmd = ["git", "-C", dd + name, "rev-parse", branch]
p = run(["git", "-C", dd + name, "reset", "--hard", p = run(["git", "-C", dd + name, "reset", "--hard",
"origin/HEAD", "-q"]) "origin/%s" % branch, "-q"])
if p.returncode != 0: if p.returncode != 0:
raise UpdateError("Error resetting to origin/HEAD") raise UpdateError("Error resetting to origin/%s" % branch)
p = run(rpcmd, stdout=PIPE) p = run(rpcmd, stdout=PIPE)
if p.returncode != 0: if p.returncode != 0:
raise UpdateError("Unable to determine old commit hash") raise UpdateError("Unable to determine old commit hash")