Merge "Only reset working copy when needed"

This commit is contained in:
Zuul 2019-01-02 21:35:27 +00:00 committed by Gerrit Code Review
commit 4540b71ff2
1 changed files with 5 additions and 4 deletions

View File

@ -268,8 +268,6 @@ class Repo(object):
head = ref.remote_head
self.log.debug("Reset to %s", head)
repo.head.reference = head
reset_repo_to_head(repo)
repo.git.clean('-x', '-f', '-d')
for ref in stale_refs:
self.log.debug("Delete stale ref %s", ref.remote_head)
# A stale ref means the upstream branch (e.g. foobar) was deleted
@ -360,9 +358,12 @@ class Repo(object):
def checkout(self, ref):
repo = self.createRepoObject()
self.log.debug("Checking out %s" % ref)
# Perform a hard reset before checking out so that we clean up
# anything that might be left over from a merge.
# Perform a hard reset to the correct ref before checking out so that
# we clean up anything that might be left over from a merge while still
# only preparing the working copy once.
repo.head.reference = ref
reset_repo_to_head(repo)
repo.git.clean('-x', '-f', '-d')
repo.git.checkout(ref)
return repo.head.commit