diff options
author | Simran Basi <sbasi@google.com> | 2015-09-23 11:38:14 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-10-01 21:05:17 +0000 |
commit | f231db11a2f7c2cf28c1228146b0c087c4be882a (patch) | |
tree | 512f2faadd94a83d5cdceec2af44e7c91a83f1f9 /subcmds | |
parent | 79360640f4c7d5f044973aa1bdb6fb0f8f311f05 (diff) | |
download | git-repo-f231db11a2f7c2cf28c1228146b0c087c4be882a.tar.gz |
GITC: Add repo gitc-delete command.
repo gitc-delete deletes a GITC client and all the locally
saved sources. Useful for removing unnecessary clients and
recovering disk space.
Change-Id: Idf23addcea52b8713d268c34a7b37da0c5e5cd26
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/gitc_delete.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/subcmds/gitc_delete.py b/subcmds/gitc_delete.py new file mode 100644 index 00000000..7380c352 --- /dev/null +++ b/subcmds/gitc_delete.py | |||
@@ -0,0 +1,55 @@ | |||
1 | # | ||
2 | # Copyright (C) 2015 The Android Open Source Project | ||
3 | # | ||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | # you may not use this file except in compliance with the License. | ||
6 | # You may obtain a copy of the License at | ||
7 | # | ||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | # | ||
10 | # Unless required by applicable law or agreed to in writing, software | ||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | # See the License for the specific language governing permissions and | ||
14 | # limitations under the License. | ||
15 | |||
16 | from __future__ import print_function | ||
17 | import os | ||
18 | import shutil | ||
19 | import sys | ||
20 | |||
21 | from command import Command, GitcClientCommand | ||
22 | import gitc_utils | ||
23 | |||
24 | from pyversion import is_python3 | ||
25 | if not is_python3(): | ||
26 | # pylint:disable=W0622 | ||
27 | input = raw_input | ||
28 | # pylint:enable=W0622 | ||
29 | |||
30 | class GitcDelete(Command, GitcClientCommand): | ||
31 | common = True | ||
32 | visible_everywhere = False | ||
33 | helpSummary = "Delete a GITC Client." | ||
34 | helpUsage = """ | ||
35 | %prog | ||
36 | """ | ||
37 | helpDescription = """ | ||
38 | This subcommand deletes the current GITC client, deleting the GITC manifest | ||
39 | and all locally downloaded sources. | ||
40 | """ | ||
41 | |||
42 | def _Options(self, p): | ||
43 | p.add_option('-f', '--force', | ||
44 | dest='force', action='store_true', | ||
45 | help='Force the deletion (no prompt).') | ||
46 | |||
47 | def Execute(self, opt, args): | ||
48 | if not opt.force: | ||
49 | prompt = ('This will delete GITC client: %s\nAre you sure? (yes/no) ' % | ||
50 | self.gitc_manifest.gitc_client_name) | ||
51 | response = input(prompt).lower() | ||
52 | if not response == 'yes': | ||
53 | print('Response was not "yes"\n Exiting...') | ||
54 | sys.exit(1) | ||
55 | shutil.rmtree(self.gitc_manifest.gitc_client_dir) | ||