mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-05-30 14:39:46 +00:00
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 <gavinmak@google.com> Reviewed-by: Becky Siegel <beckysiegel@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
a98e422113
commit
a6bc1b7cf0
+5
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user