summaryrefslogtreecommitdiffstats
path: root/tests/test_subcmds_sync.py
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2025-07-23 15:23:10 -0700
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2025-07-23 15:57:49 -0700
commit720bd1e96b4e9c36d035987578fc01a9939d753f (patch)
tree27ea0e54c715dd02909bc9932f9c2a89b892a23f /tests/test_subcmds_sync.py
parent25858c8b16264beca64bf22b91588fa6694b2b07 (diff)
downloadgit-repo-2.57.1.tar.gz
sync: Don't checkout if no worktreev2.57.1stable
Interleaved sync should not try checkout out a project if it's a mirror. Change-Id: I2549faab197a3202d79a10e44b449b68d53e3fe7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/492942 Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Scott Lee <ddoman@google.com> Tested-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'tests/test_subcmds_sync.py')
-rw-r--r--tests/test_subcmds_sync.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py
index 9cd19f10..5955e404 100644
--- a/tests/test_subcmds_sync.py
+++ b/tests/test_subcmds_sync.py
@@ -309,6 +309,7 @@ class FakeProject:
309 self.relpath = relpath 309 self.relpath = relpath
310 self.name = name or relpath 310 self.name = name or relpath
311 self.objdir = objdir or relpath 311 self.objdir = objdir or relpath
312 self.worktree = relpath
312 313
313 self.use_git_worktrees = False 314 self.use_git_worktrees = False
314 self.UseAlternates = False 315 self.UseAlternates = False
@@ -836,6 +837,25 @@ class InterleavedSyncTest(unittest.TestCase):
836 project.Sync_NetworkHalf.assert_called_once() 837 project.Sync_NetworkHalf.assert_called_once()
837 project.Sync_LocalHalf.assert_not_called() 838 project.Sync_LocalHalf.assert_not_called()
838 839
840 def test_worker_no_worktree(self):
841 """Test interleaved sync does not checkout with no worktree."""
842 opt = self._get_opts()
843 project = self.projA
844 project.worktree = None
845 project.Sync_NetworkHalf = mock.Mock(
846 return_value=SyncNetworkHalfResult(error=None, remote_fetched=True)
847 )
848 project.Sync_LocalHalf = mock.Mock()
849 self.mock_context["projects"] = [project]
850
851 result_obj = self.cmd._SyncProjectList(opt, [0])
852 result = result_obj.results[0]
853
854 self.assertTrue(result.fetch_success)
855 self.assertTrue(result.checkout_success)
856 project.Sync_NetworkHalf.assert_called_once()
857 project.Sync_LocalHalf.assert_not_called()
858
839 def test_worker_fetch_fails_exception(self): 859 def test_worker_fetch_fails_exception(self):
840 """Test _SyncProjectList with an exception during fetch.""" 860 """Test _SyncProjectList with an exception during fetch."""
841 opt = self._get_opts() 861 opt = self._get_opts()