Use 'git checkout' when checking out a tag

The way we were checking out tags did not match the results that would
happen from a simple 'git checkout tagname', which made it difficult for
us to push repos from the executor to the workers.  It may also have
eventually caused inconsistent results with git tooling in jobs since
it didn't match the way most folks would check out a tag.  (In particular,
this method did not appear to update .git/logs/HEAD, which is used by
git status.)

Change to just use the git checkout command rather than the lower-level
manipulation we were doing.

Change-Id: I77e9900c73caf16032dbadb9991358caed0e07ed
This commit is contained in:
James E. Blair 2017-09-08 16:04:52 -07:00
parent 25796c229c
commit f49b525b3c
1 changed files with 4 additions and 1 deletions

View File

@ -191,11 +191,14 @@ class Repo(object):
def checkout(self, ref):
repo = self.createRepoObject()
self.log.debug("Checking out %s" % ref)
repo.head.reference = ref
# Perform a hard reset before checking out so that we clean up
# anything that might be left over from a merge.
reset_repo_to_head(repo)
repo.git.checkout(ref)
return repo.head.commit
def checkoutLocalBranch(self, branch):
# TODO(jeblair): retire in favor of checkout
repo = self.createRepoObject()
# Perform a hard reset before checking out so that we clean up
# anything that might be left over from a merge.