13
13
# limitations under the License.
14
14
15
15
import os
16
- from typing import Set
16
+ from typing import List , Set
17
17
18
18
from command import Command
19
19
import platform_utils
20
20
from progress import Progress
21
+ from project import Project
21
22
22
23
23
24
class Gc (Command ):
@@ -64,10 +65,7 @@ def _find_git_to_delete(
64
65
65
66
return to_delete
66
67
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 ):
71
69
print (f"Scanning filesystem under { self .repodir } ..." )
72
70
73
71
project_paths = set ()
@@ -90,11 +88,11 @@ def Execute(self, opt, args):
90
88
91
89
if not to_delete :
92
90
print ("Nothing to clean up." )
93
- return
91
+ return 0
94
92
95
93
print ("Identified the following projects are no longer used:" )
96
94
print ("\n " .join (to_delete ))
97
- print ("\n " )
95
+ print ("" )
98
96
if not opt .yes :
99
97
print (
100
98
"If you proceed, any local commits in those projects will be "
@@ -125,3 +123,12 @@ def Execute(self, opt, args):
125
123
platform_utils .rmtree (tmp_path )
126
124
pm .update (msg = path )
127
125
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