mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-20 16:14:25 +00:00
gc: extract deletion from Execute method
Change-Id: Icef4f28fbdb9658892611def7589f5eba43c952c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/447721 Reviewed-by: Scott Lee <ddoman@google.com> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org> Tested-by: Josip Sokcevic <sokcevic@chromium.org>
This commit is contained in:
parent
d93fe60e89
commit
41a27eb854
@ -13,11 +13,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from typing import Set
|
from typing import List, Set
|
||||||
|
|
||||||
from command import Command
|
from command import Command
|
||||||
import platform_utils
|
import platform_utils
|
||||||
from progress import Progress
|
from progress import Progress
|
||||||
|
from project import Project
|
||||||
|
|
||||||
|
|
||||||
class Gc(Command):
|
class Gc(Command):
|
||||||
@ -64,10 +65,7 @@ class Gc(Command):
|
|||||||
|
|
||||||
return to_delete
|
return to_delete
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def delete_unused_projects(self, projects: List[Project], opt):
|
||||||
projects = self.GetProjects(
|
|
||||||
args, all_manifests=not opt.this_manifest_only
|
|
||||||
)
|
|
||||||
print(f"Scanning filesystem under {self.repodir}...")
|
print(f"Scanning filesystem under {self.repodir}...")
|
||||||
|
|
||||||
project_paths = set()
|
project_paths = set()
|
||||||
@ -90,11 +88,11 @@ class Gc(Command):
|
|||||||
|
|
||||||
if not to_delete:
|
if not to_delete:
|
||||||
print("Nothing to clean up.")
|
print("Nothing to clean up.")
|
||||||
return
|
return 0
|
||||||
|
|
||||||
print("Identified the following projects are no longer used:")
|
print("Identified the following projects are no longer used:")
|
||||||
print("\n".join(to_delete))
|
print("\n".join(to_delete))
|
||||||
print("\n")
|
print("")
|
||||||
if not opt.yes:
|
if not opt.yes:
|
||||||
print(
|
print(
|
||||||
"If you proceed, any local commits in those projects will be "
|
"If you proceed, any local commits in those projects will be "
|
||||||
@ -125,3 +123,12 @@ class Gc(Command):
|
|||||||
platform_utils.rmtree(tmp_path)
|
platform_utils.rmtree(tmp_path)
|
||||||
pm.update(msg=path)
|
pm.update(msg=path)
|
||||||
pm.end()
|
pm.end()
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def Execute(self, opt, args):
|
||||||
|
projects: List[Project] = self.GetProjects(
|
||||||
|
args, all_manifests=not opt.this_manifest_only
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.delete_unused_projects(projects, opt)
|
||||||
|
Loading…
Reference in New Issue
Block a user