diff options
Diffstat (limited to 'repo')
-rwxr-xr-x | repo | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -108,7 +108,7 @@ S_repo = 'repo' # special repo repository | |||
108 | S_manifests = 'manifests' # special manifest repository | 108 | S_manifests = 'manifests' # special manifest repository |
109 | REPO_MAIN = S_repo + '/main.py' # main script | 109 | REPO_MAIN = S_repo + '/main.py' # main script |
110 | MIN_PYTHON_VERSION = (2, 6) # minimum supported python version | 110 | MIN_PYTHON_VERSION = (2, 6) # minimum supported python version |
111 | GITC_MANIFEST_DIR = '/usr/local/google/gitc' | 111 | GITC_CONFIG_FILE = '/gitc/.config' |
112 | 112 | ||
113 | 113 | ||
114 | import errno | 114 | import errno |
@@ -222,6 +222,20 @@ def _GitcInitOptions(init_optparse): | |||
222 | dest='gitc_client', | 222 | dest='gitc_client', |
223 | help='The name for the new gitc_client instance.') | 223 | help='The name for the new gitc_client instance.') |
224 | 224 | ||
225 | _gitc_manifest_dir = None | ||
226 | def get_gitc_manifest_dir(): | ||
227 | global _gitc_manifest_dir | ||
228 | if _gitc_manifest_dir is None: | ||
229 | try: | ||
230 | with open(GITC_CONFIG_FILE, 'r') as gitc_config: | ||
231 | for line in gitc_config: | ||
232 | match = re.match('gitc_dir=(?P<gitc_manifest_dir>.*)', line) | ||
233 | if match: | ||
234 | _gitc_manifest_dir = match.group('gitc_manifest_dir') | ||
235 | except IOError: | ||
236 | _gitc_manifest_dir = '' | ||
237 | return _gitc_manifest_dir | ||
238 | |||
225 | class CloneFailure(Exception): | 239 | class CloneFailure(Exception): |
226 | """Indicate the remote clone of repo itself failed. | 240 | """Indicate the remote clone of repo itself failed. |
227 | """ | 241 | """ |
@@ -255,7 +269,12 @@ def _Init(args, gitc_init=False): | |||
255 | 269 | ||
256 | try: | 270 | try: |
257 | if gitc_init: | 271 | if gitc_init: |
258 | client_dir = os.path.join(GITC_MANIFEST_DIR, opt.gitc_client) | 272 | gitc_manifest_dir = get_gitc_manifest_dir() |
273 | if not gitc_manifest_dir: | ||
274 | _print('error: GITC filesystem is not running. Exiting...', | ||
275 | file=sys.stderr) | ||
276 | sys.exit(1) | ||
277 | client_dir = os.path.join(gitc_manifest_dir, opt.gitc_client) | ||
259 | if not os.path.exists(client_dir): | 278 | if not os.path.exists(client_dir): |
260 | os.makedirs(client_dir) | 279 | os.makedirs(client_dir) |
261 | os.chdir(client_dir) | 280 | os.chdir(client_dir) |
@@ -746,6 +765,12 @@ def main(orig_args): | |||
746 | wrapper_path = os.path.abspath(__file__) | 765 | wrapper_path = os.path.abspath(__file__) |
747 | my_main, my_git = _RunSelf(wrapper_path) | 766 | my_main, my_git = _RunSelf(wrapper_path) |
748 | 767 | ||
768 | cwd = os.getcwd() | ||
769 | if cwd.startswith(get_gitc_manifest_dir()): | ||
770 | _print('error: repo cannot be used in the GITC local manifest directory.' | ||
771 | '\nIf you want to work on this GITC client please rerun this ' | ||
772 | 'command from the corresponding client under /gitc/', file=sys.stderr) | ||
773 | sys.exit(1) | ||
749 | if not repo_main: | 774 | if not repo_main: |
750 | if opt.help: | 775 | if opt.help: |
751 | _Usage() | 776 | _Usage() |