Skip to content

Commit 41a27eb

Browse files
sokcevicGLUCI
authored andcommitted
gc: extract deletion from Execute method
Change-Id: Icef4f28fbdb9658892611def7589f5eba43c952c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/447721 Reviewed-by: Scott Lee <[email protected]> Commit-Queue: Josip Sokcevic <[email protected]> Tested-by: Josip Sokcevic <[email protected]>
1 parent d93fe60 commit 41a27eb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

subcmds/gc.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# limitations under the License.
1414

1515
import os
16-
from typing import Set
16+
from typing import List, Set
1717

1818
from command import Command
1919
import platform_utils
2020
from progress import Progress
21+
from project import Project
2122

2223

2324
class Gc(Command):
@@ -64,10 +65,7 @@ def _find_git_to_delete(
6465

6566
return to_delete
6667

67-
def Execute(self, opt, args):
68-
projects = self.GetProjects(
69-
args, all_manifests=not opt.this_manifest_only
70-
)
68+
def delete_unused_projects(self, projects: List[Project], opt):
7169
print(f"Scanning filesystem under {self.repodir}...")
7270

7371
project_paths = set()
@@ -90,11 +88,11 @@ def Execute(self, opt, args):
9088

9189
if not to_delete:
9290
print("Nothing to clean up.")
93-
return
91+
return 0
9492

9593
print("Identified the following projects are no longer used:")
9694
print("\n".join(to_delete))
97-
print("\n")
95+
print("")
9896
if not opt.yes:
9997
print(
10098
"If you proceed, any local commits in those projects will be "
@@ -125,3 +123,12 @@ def Execute(self, opt, args):
125123
platform_utils.rmtree(tmp_path)
126124
pm.update(msg=path)
127125
pm.end()
126+
127+
return 0
128+
129+
def Execute(self, opt, args):
130+
projects: List[Project] = self.GetProjects(
131+
args, all_manifests=not opt.this_manifest_only
132+
)
133+
134+
return self.delete_unused_projects(projects, opt)

0 commit comments

Comments
 (0)