diff options
Diffstat (limited to 'subcmds/gitc_init.py')
-rw-r--r-- | subcmds/gitc_init.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index 4f9d7344..2726eaec 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py | |||
@@ -21,6 +21,7 @@ import gitc_utils | |||
21 | from command import GitcAvailableCommand | 21 | from command import GitcAvailableCommand |
22 | from manifest_xml import GitcManifest | 22 | from manifest_xml import GitcManifest |
23 | from subcmds import init | 23 | from subcmds import init |
24 | import wrapper | ||
24 | 25 | ||
25 | 26 | ||
26 | class GitcInit(init.Init, GitcAvailableCommand): | 27 | class GitcInit(init.Init, GitcAvailableCommand): |
@@ -55,18 +56,15 @@ use for this GITC client. | |||
55 | help='Optional manifest file to use for this GITC client.') | 56 | help='Optional manifest file to use for this GITC client.') |
56 | g.add_option('-c', '--gitc-client', | 57 | g.add_option('-c', '--gitc-client', |
57 | dest='gitc_client', | 58 | dest='gitc_client', |
58 | help='The name for the new gitc_client instance.') | 59 | help='The name of the gitc_client instance to create or modify.') |
59 | 60 | ||
60 | def Execute(self, opt, args): | 61 | def Execute(self, opt, args): |
61 | if not opt.gitc_client: | 62 | gitc_client = gitc_utils.parse_clientdir(os.getcwd()) |
62 | print('fatal: gitc client (-c) is required', file=sys.stderr) | 63 | if not gitc_client or (opt.gitc_client and gitc_client != opt.gitc_client): |
64 | print('fatal: Please update your repo command. See go/gitc for instructions.', file=sys.stderr) | ||
63 | sys.exit(1) | 65 | sys.exit(1) |
64 | self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), | 66 | self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), |
65 | opt.gitc_client) | 67 | gitc_client) |
66 | if not os.path.exists(gitc_utils.get_gitc_manifest_dir()): | ||
67 | os.makedirs(gitc_utils.get_gitc_manifest_dir()) | ||
68 | if not os.path.exists(self.client_dir): | ||
69 | os.mkdir(self.client_dir) | ||
70 | super(GitcInit, self).Execute(opt, args) | 68 | super(GitcInit, self).Execute(opt, args) |
71 | 69 | ||
72 | manifest_file = self.manifest.manifestFile | 70 | manifest_file = self.manifest.manifestFile |
@@ -77,8 +75,8 @@ use for this GITC client. | |||
77 | sys.exit(1) | 75 | sys.exit(1) |
78 | manifest_file = opt.manifest_file | 76 | manifest_file = opt.manifest_file |
79 | 77 | ||
80 | manifest = GitcManifest(self.repodir, opt.gitc_client) | 78 | manifest = GitcManifest(self.repodir, gitc_client) |
81 | manifest.Override(manifest_file) | 79 | manifest.Override(manifest_file) |
82 | gitc_utils.generate_gitc_manifest(None, manifest) | 80 | gitc_utils.generate_gitc_manifest(None, manifest) |
83 | print('Please run `cd %s` to view your GITC client.' % | 81 | print('Please run `cd %s` to view your GITC client.' % |
84 | os.path.join(gitc_utils.GITC_FS_ROOT_DIR, opt.gitc_client)) | 82 | os.path.join(wrapper.Wrapper().GITC_FS_ROOT_DIR, gitc_client)) |