From a6bc1b7cf0b4c71f9448eb57a2d478049d356c65 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Mon, 11 May 2026 19:19:14 +0000 Subject: [PATCH] sync: Exclude stateless sync pruned projects from bloat check If a project has been pruned for stateless sync, it has already undergone aggressive garbage collection. There should be no bloat to check for. Change-Id: I9233a4611e05b7a0b7c097827d6f408144f7380d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581841 Tested-by: Gavin Mak Reviewed-by: Becky Siegel Commit-Queue: Gavin Mak --- subcmds/sync.py | 6 +++++- tests/test_subcmds_sync.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index 5aec277a0..b1c30867e 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -1459,7 +1459,11 @@ later is required to fix a server side protocol bug. if not git_require((2, 23, 0)): return - projects = [p for p in projects if p.clone_depth] + projects = [ + p + for p in projects + if p.clone_depth and not p.stateless_prune_needed + ] if not projects: return diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py index b3726d2d1..0a46bbdf3 100644 --- a/tests/test_subcmds_sync.py +++ b/tests/test_subcmds_sync.py @@ -489,6 +489,7 @@ class CheckForBloatedProjects(unittest.TestCase): self.project.name = "project" self.project.Exists = True self.project.worktree = "worktree" + self.project.stateless_prune_needed = False self.cmd.git_event_log = mock.MagicMock() self.cmd._bloated_projects = [] @@ -530,6 +531,21 @@ class CheckForBloatedProjects(unittest.TestCase): self.assertEqual(self.cmd._bloated_projects, ["project"]) + @mock.patch("subcmds.sync.git_require") + @mock.patch("subcmds.sync.Progress") + def test_stateless_prune_excluded(self, mock_progress, mock_git_require): + """Test that projects pruned for stateless sync are excluded.""" + mock_git_require.return_value = True + self.project.stateless_prune_needed = True + + self.cmd.ExecuteInParallel = mock.Mock() + + with mock.patch.object(self.cmd, "ParallelContext"): + self.cmd._CheckForBloatedProjects([self.project], self.opt) + + self.assertFalse(self.cmd.ExecuteInParallel.called) + self.assertEqual(self.cmd._bloated_projects, []) + class GCProjectsTest(unittest.TestCase): """Tests for Sync._GCProjects."""