mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-05-30 06:29:52 +00:00
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>
This commit is contained in:
+10
-1
@@ -284,7 +284,16 @@ class Gc(Command):
|
||||
args, all_manifests=not opt.this_manifest_only
|
||||
)
|
||||
|
||||
ret = self.delete_unused_projects(projects, opt)
|
||||
# If the user specified projects, fetch the global list separately
|
||||
# to avoid deleting untargeted projects.
|
||||
if args:
|
||||
all_projects = self.GetProjects(
|
||||
[], all_manifests=not opt.this_manifest_only
|
||||
)
|
||||
else:
|
||||
all_projects = projects
|
||||
|
||||
ret = self.delete_unused_projects(all_projects, opt)
|
||||
if ret != 0:
|
||||
return ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user