Commit 9e8fb0e5 authored by Aleksandr Derbenev's avatar Aleksandr Derbenev Committed by Commit Bot

Add --cache-dir argument to gclient.

There are some usecases where it is simpler to pass path to the 
cache by an environment variable or command-line argument 
than to modify the gclient config file.

With this change:

 * GCLIENT_CACHE_DIR environment variable overrides cache_dir variable
   from .gclient file.

 * --cache-dir argument moved from gclient config to all gclient
   commands and overrides values from .gclient file and environment
   variable.

R=dpranke@chromium.org

Bug:
Change-Id: Iae107f1d5f02a2eee1896d0d3108dc20a83d597f
Reviewed-on: https://chromium-review.googlesource.com/596089Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: 's avatarDaniel Jacques <dnj@chromium.org>
Commit-Queue: Aleksandr Derbenev <alex-ac@yandex-team.ru>
parent 9ff56883
......@@ -1267,7 +1267,7 @@ it or fix the checkout.
else:
self._enforced_os = tuple(set(self._enforced_os).union(target_os))
cache_dir = config_dict.get('cache_dir')
cache_dir = config_dict.get('cache_dir', self._options.cache_dir)
if cache_dir:
cache_dir = os.path.join(self.root_dir, cache_dir)
cache_dir = os.path.abspath(cache_dir)
......@@ -2043,10 +2043,6 @@ def CMDconfig(parser, args):
'to have the main solution untouched by gclient '
'(gclient will check out unmanaged dependencies but '
'will never sync them)')
parser.add_option('--cache-dir',
help='(git only) Cache all git repos into this dir and do '
'shared clones from the cache, instead of cloning '
'directly from the remote. (experimental)')
parser.set_defaults(config_filename=None)
(options, args) = parser.parse_args(args)
if options.output_config_file:
......@@ -2417,6 +2413,12 @@ class OptionParser(optparse.OptionParser):
'--spec',
help='create a gclient file containing the provided string. Due to '
'Cygwin/Python brokenness, it can\'t contain any newlines.')
self.add_option(
'--cache-dir',
help='(git only) Cache all git repos into this dir and do '
'shared clones from the cache, instead of cloning '
'directly from the remote. (experimental)',
default=os.environ.get('GCLIENT_CACHE_DIR'))
self.add_option(
'--no-nag-max', default=False, action='store_true',
help='Ignored for backwards compatibility.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment