mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
auto merge of #4302 : SimonSapin/servo/clean-snapshots, r=Manishearth
Bootstrapping automatically downloads new Rust and Cargo snapshots as needed into versioned directories, but do not remove now-unused versions. This is the desired behavior for `git bisect` to be usable. However, this means that old version keep accumulating, taking up disk space. This adds a mach command to remove snapshots other than the ones currently being used. It is never run automatically. To be safe, the command defaults to only printing what would be removed, and only removes stuff when run with a `-f` argument. r? @mbrubeck
This commit is contained in:
commit
00298221a6
1 changed files with 29 additions and 0 deletions
|
@ -152,3 +152,32 @@ class MachCommands(CommandBase):
|
||||||
["git", "submodule", "--quiet", "sync", "--recursive"])
|
["git", "submodule", "--quiet", "sync", "--recursive"])
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
["git", "submodule", "update", "--init", "--recursive"])
|
["git", "submodule", "update", "--init", "--recursive"])
|
||||||
|
|
||||||
|
@Command('clean-snapshots',
|
||||||
|
description='Clean unused snapshots of Rust and Cargo',
|
||||||
|
category='bootstrap')
|
||||||
|
@CommandArgument('--force', '-f',
|
||||||
|
action='store_true',
|
||||||
|
help='Actually remove stuff')
|
||||||
|
def clean_snapshots(self, force=False):
|
||||||
|
rust_current = self.rust_snapshot_path().split('/')[0]
|
||||||
|
cargo_current = self.cargo_build_id()
|
||||||
|
print("Current Rust version: " + rust_current)
|
||||||
|
print("Current Cargo version: " + cargo_current)
|
||||||
|
removing_anything = False
|
||||||
|
for current, base in [(rust_current, "rust"), (cargo_current, "cargo")]:
|
||||||
|
base = path.join(self.context.sharedir, base)
|
||||||
|
for name in os.listdir(base):
|
||||||
|
if name != current:
|
||||||
|
removing_anything = True
|
||||||
|
name = path.join(base, name)
|
||||||
|
if force:
|
||||||
|
print("Removing " + name)
|
||||||
|
shutil.rmtree(name)
|
||||||
|
else:
|
||||||
|
print("Would remove " + name)
|
||||||
|
if not removing_anything:
|
||||||
|
print("Nothing to remove.")
|
||||||
|
elif not force:
|
||||||
|
print("Nothing done. "
|
||||||
|
"Run `./mach clean-snapshots -f` to actually remove.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue