summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJosef Malmström <josef.malmstrom@arm.com>2026-05-04 14:01:36 +0200
committergerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-05-06 08:53:27 -0700
commite3eadd37289f3c8bf0b71aeab50b86e130ead539 (patch)
treeefe01f580e947d0c1d96c7b292b09cd96c340bbb /tests
parent12cfc6036a590fa8b573e9ebec0a2873956668b2 (diff)
downloadgit-repo-e3eadd37289f3c8bf0b71aeab50b86e130ead539.tar.gz
sync: Fix force_checkout propagation
The force_checkout parameter was not propagated in all calls to Checkout in Sync_LocalHalf. Without this, repo sync --force-checkout can still fail for projects currently on a local branch with no upstream/tracking configuration, because the detach-to-manifest checkout was executed without -f, leaving local modifications or untracked files able to block sync. Change-Id: I58551388e2f906c4db96e220707a369057a71c24 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579181 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_project.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_project.py b/tests/test_project.py
index 6a04ea455..1deec0726 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -663,6 +663,36 @@ class StatelessSyncTests(unittest.TestCase):
663 capture_stderr=True, 663 capture_stderr=True,
664 ) 664 )
665 665
666 def test_sync_local_half_no_upstream_propagates_force_checkout(self):
667 """Test Sync_LocalHalf forwards force_checkout when detaching."""
668 with utils_for_test.TempGitTree() as tempdir:
669 proj = self._get_project(tempdir)
670
671 proj._InitWorkTree = mock.MagicMock()
672 proj.CleanPublishedCache = mock.MagicMock()
673 proj.GetRevisionId = mock.MagicMock(return_value="1234abcd")
674 proj._Checkout = mock.MagicMock()
675 proj._CopyAndLinkFiles = mock.MagicMock()
676
677 proj.work_git = mock.MagicMock()
678 proj.work_git.GetHead.return_value = "refs/heads/topic"
679
680 proj.bare_ref = mock.MagicMock()
681 proj.bare_ref.all = {"refs/heads/topic": "5678abcd"}
682
683 branch = mock.MagicMock()
684 branch.name = "topic"
685 branch.LocalMerge = False
686 proj.GetBranch = mock.MagicMock(return_value=branch)
687
688 syncbuf = project.SyncBuffer(proj.config)
689 proj.Sync_LocalHalf(syncbuf, force_checkout=True)
690
691 proj._Checkout.assert_called_once_with(
692 "1234abcd", force_checkout=True, quiet=True
693 )
694 proj._CopyAndLinkFiles.assert_called_once_with()
695
666 def test_sync_network_half_stateless_skips_if_stash(self): 696 def test_sync_network_half_stateless_skips_if_stash(self):
667 """Test stateless sync skips if stash exists.""" 697 """Test stateless sync skips if stash exists."""
668 with utils_for_test.TempGitTree() as tempdir: 698 with utils_for_test.TempGitTree() as tempdir: