summaryrefslogtreecommitdiffstats
path: root/subcmds/gc.py
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2026-02-06 20:54:20 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-02-09 08:34:42 -0800
commit5cb0251248111129d1bd7f5ad396ba65c7695768 (patch)
tree6504be1f938bc912bc4a44bd7c68d2ef498de23e /subcmds/gc.py
parenta214fd31bd477dda2708ab9f3bc675081ceff696 (diff)
downloadgit-repo-5cb0251248111129d1bd7f5ad396ba65c7695768.tar.gz
gc: fix untargeted projects being deleted
`delete_unused_projects` needs a full list of active projects to figure out which orphaned .git dirs need to be deleted. Otherwise it thinks that only the projects specified in args are active. Bug: 447626164 Change-Id: I02beebf6a01c77742a8db78221452d71cd78ea73 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/550061 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds/gc.py')
-rw-r--r--subcmds/gc.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/subcmds/gc.py b/subcmds/gc.py
index 4e5bcabff..a23d5e068 100644
--- a/subcmds/gc.py
+++ b/subcmds/gc.py
@@ -284,7 +284,16 @@ class Gc(Command):
284 args, all_manifests=not opt.this_manifest_only 284 args, all_manifests=not opt.this_manifest_only
285 ) 285 )
286 286
287 ret = self.delete_unused_projects(projects, opt) 287 # If the user specified projects, fetch the global list separately
288 # to avoid deleting untargeted projects.
289 if args:
290 all_projects = self.GetProjects(
291 [], all_manifests=not opt.this_manifest_only
292 )
293 else:
294 all_projects = projects
295
296 ret = self.delete_unused_projects(all_projects, opt)
288 if ret != 0: 297 if ret != 0:
289 return ret 298 return ret
290 299