diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-10-06 15:23:19 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-10-07 15:43:22 -0700 |
commit | 745b4ad660f8050045b521c4e15b7d3ac0b3d70e (patch) | |
tree | 643e836eafdde0c08e1eec540eab6ae23b2ef29e /subcmds | |
parent | 4c5f74e4521679d1dcc31c575d417387b9c51c87 (diff) | |
download | git-repo-745b4ad660f8050045b521c4e15b7d3ac0b3d70e.tar.gz |
Fix gitc-init behaviorv1.12.32
With gitc-init, a gitc client may be specified using '-c'. If we're
not currently in that client, we need to change directories so that
we don't affect the local checkout, and to ensure that repo is
checked out in the new client.
This also makes '-c' optional if already in a gitc client, to match
the rest of the init options.
Change-Id: Ib514ad9fd101698060ae89bb035499800897e9bd
Diffstat (limited to 'subcmds')
-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)) |