summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-02 21:35:27 +0000
committerGerrit Code Review <review@openstack.org>2019-01-02 21:35:27 +0000
commit4540b71ff27f15c86e86e377afc5bd7e6d58aad4 (patch)
treee0b5d9388efdc912f03bcdb1036d85018c77d317
parent7d3ad9a7aa0f1bebf54ece9ec390948e8e16b3c2 (diff)
parentbd6c60b36990510a3993e6e63873767258567bde (diff)
Merge "Only reset working copy when needed"
-rw-r--r--zuul/merger/merger.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/zuul/merger/merger.py b/zuul/merger/merger.py
index fff7e16..0c14fbf 100644
--- a/zuul/merger/merger.py
+++ b/zuul/merger/merger.py
@@ -268,8 +268,6 @@ class Repo(object):
268 head = ref.remote_head 268 head = ref.remote_head
269 self.log.debug("Reset to %s", head) 269 self.log.debug("Reset to %s", head)
270 repo.head.reference = head 270 repo.head.reference = head
271 reset_repo_to_head(repo)
272 repo.git.clean('-x', '-f', '-d')
273 for ref in stale_refs: 271 for ref in stale_refs:
274 self.log.debug("Delete stale ref %s", ref.remote_head) 272 self.log.debug("Delete stale ref %s", ref.remote_head)
275 # A stale ref means the upstream branch (e.g. foobar) was deleted 273 # A stale ref means the upstream branch (e.g. foobar) was deleted
@@ -360,9 +358,12 @@ class Repo(object):
360 def checkout(self, ref): 358 def checkout(self, ref):
361 repo = self.createRepoObject() 359 repo = self.createRepoObject()
362 self.log.debug("Checking out %s" % ref) 360 self.log.debug("Checking out %s" % ref)
363 # Perform a hard reset before checking out so that we clean up 361 # Perform a hard reset to the correct ref before checking out so that
364 # anything that might be left over from a merge. 362 # we clean up anything that might be left over from a merge while still
363 # only preparing the working copy once.
364 repo.head.reference = ref
365 reset_repo_to_head(repo) 365 reset_repo_to_head(repo)
366 repo.git.clean('-x', '-f', '-d')
366 repo.git.checkout(ref) 367 repo.git.checkout(ref)
367 return repo.head.commit 368 return repo.head.commit
368 369