Skip to content

Commit

Permalink
Fetch revision if not present from clone. (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwartzentruber authored Dec 1, 2022
1 parent 01e933d commit f7337d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions taskboot/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ def clone(self, repository, revision):
subprocess.check_output(cmd)
logger.info("Cloned into {}".format(self.dir))

# Explicitly fetch revision if it isn't present
# This is necessary when revision is from a fork
# and repository is the base repo.
if (
subprocess.run(
["git", "show", revision],
cwd=self.dir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
!= 0
):
cmd = ["git", "fetch", "--quiet", "origin", revision]
subprocess.check_output(cmd, cwd=self.dir)

# Checkout revision to pull modifications
cmd = ["git", "checkout", revision, "-b", "taskboot"]
subprocess.check_output(cmd, cwd=self.dir)
Expand Down

0 comments on commit f7337d2

Please sign in to comment.