Browse Source

Merge "Only reset working copy when needed"

tags/3.4.0
Zuul 5 months ago
parent
commit
4540b71ff2
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      zuul/merger/merger.py

+ 5
- 4
zuul/merger/merger.py View File

@@ -268,8 +268,6 @@ class Repo(object):
268 268
                 head = ref.remote_head
269 269
         self.log.debug("Reset to %s", head)
270 270
         repo.head.reference = head
271
-        reset_repo_to_head(repo)
272
-        repo.git.clean('-x', '-f', '-d')
273 271
         for ref in stale_refs:
274 272
             self.log.debug("Delete stale ref %s", ref.remote_head)
275 273
             # A stale ref means the upstream branch (e.g. foobar) was deleted
@@ -360,9 +358,12 @@ class Repo(object):
360 358
     def checkout(self, ref):
361 359
         repo = self.createRepoObject()
362 360
         self.log.debug("Checking out %s" % ref)
363
-        # Perform a hard reset before checking out so that we clean up
364
-        # anything that might be left over from a merge.
361
+        # Perform a hard reset to the correct ref before checking out so that
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 365
         reset_repo_to_head(repo)
366
+        repo.git.clean('-x', '-f', '-d')
366 367
         repo.git.checkout(ref)
367 368
         return repo.head.commit
368 369
 

Loading…
Cancel
Save