mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
fetch: make --no-history and --no-hooks switches consistent
Before this commit, the following switches exist: - --nohooks - --no-history They are not consistent. This commit makes the following switches available: - --nohooks, --no-hooks - --nohistory, --no-history Bug: None Change-Id: Iaea2357c05e3dc69e3fac0fb9d823db903d811bb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3904446 Auto-Submit: Thiago Perrotta <tperrotta@chromium.org> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
19
fetch.py
19
fetch.py
@@ -140,7 +140,7 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
|
||||
sync_cmd = ['sync']
|
||||
if self.options.nohooks:
|
||||
sync_cmd.append('--nohooks')
|
||||
if self.options.no_history:
|
||||
if self.options.nohistory:
|
||||
sync_cmd.append('--no-history')
|
||||
if self.spec.get('with_branch_heads', False):
|
||||
sync_cmd.append('--with_branch_heads')
|
||||
@@ -154,7 +154,7 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
|
||||
'submodule', 'foreach',
|
||||
'git config -f $toplevel/.git/config submodule.$name.ignore all',
|
||||
cwd=wd)
|
||||
if not self.options.no_history:
|
||||
if not self.options.nohistory:
|
||||
self.run_git(
|
||||
'config', '--add', 'remote.origin.fetch',
|
||||
'+refs/tags/*:refs/tags/*', cwd=wd)
|
||||
@@ -194,10 +194,17 @@ def handle_args(argv):
|
||||
|
||||
parser.add_argument('-n', '--dry-run', action='store_true', default=False,
|
||||
help='Don\'t run commands, only print them.')
|
||||
parser.add_argument('--nohooks', action='store_true', default=False,
|
||||
help='Don\'t run hooks after checkout.')
|
||||
parser.add_argument('--no-history', action='store_true', default=False,
|
||||
help='Perform shallow clones, don\'t fetch the full git history.')
|
||||
parser.add_argument('--nohooks',
|
||||
'--no-hooks',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Don\'t run hooks after checkout.')
|
||||
parser.add_argument(
|
||||
'--nohistory',
|
||||
'--no-history',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Perform shallow clones, don\'t fetch the full git history.')
|
||||
parser.add_argument('--force', action='store_true', default=False,
|
||||
help='(dangerous) Don\'t look for existing .gclient file.')
|
||||
parser.add_argument(
|
||||
|
||||
@@ -48,40 +48,40 @@ class TestUtilityFunctions(unittest.TestCase):
|
||||
|
||||
def test_handle_args_valid_usage(self):
|
||||
response = fetch.handle_args(['filename', 'foo'])
|
||||
self.assertEqual(argparse.Namespace(
|
||||
dry_run=False,
|
||||
nohooks=False,
|
||||
no_history=False,
|
||||
force=False,
|
||||
config='foo',
|
||||
protocol_override=None,
|
||||
props=[]), response)
|
||||
self.assertEqual(
|
||||
argparse.Namespace(dry_run=False,
|
||||
nohooks=False,
|
||||
nohistory=False,
|
||||
force=False,
|
||||
config='foo',
|
||||
protocol_override=None,
|
||||
props=[]), response)
|
||||
|
||||
response = fetch.handle_args([
|
||||
'filename', '-n', '--dry-run', '--nohooks', '--no-history', '--force',
|
||||
'--protocol-override', 'sso', 'foo', '--some-param=1', '--bar=2'
|
||||
])
|
||||
self.assertEqual(argparse.Namespace(
|
||||
dry_run=True,
|
||||
nohooks=True,
|
||||
no_history=True,
|
||||
force=True,
|
||||
config='foo',
|
||||
protocol_override='sso',
|
||||
props=['--some-param=1', '--bar=2']), response)
|
||||
self.assertEqual(
|
||||
argparse.Namespace(dry_run=True,
|
||||
nohooks=True,
|
||||
nohistory=True,
|
||||
force=True,
|
||||
config='foo',
|
||||
protocol_override='sso',
|
||||
props=['--some-param=1', '--bar=2']), response)
|
||||
|
||||
response = fetch.handle_args([
|
||||
'filename', '-n', '--dry-run', '--nohooks', '--no-history', '--force',
|
||||
'filename', '-n', '--dry-run', '--no-hooks', '--nohistory', '--force',
|
||||
'-p', 'sso', 'foo', '--some-param=1', '--bar=2'
|
||||
])
|
||||
self.assertEqual(argparse.Namespace(
|
||||
dry_run=True,
|
||||
nohooks=True,
|
||||
no_history=True,
|
||||
force=True,
|
||||
config='foo',
|
||||
protocol_override='sso',
|
||||
props=['--some-param=1', '--bar=2']), response)
|
||||
self.assertEqual(
|
||||
argparse.Namespace(dry_run=True,
|
||||
nohooks=True,
|
||||
nohistory=True,
|
||||
force=True,
|
||||
config='foo',
|
||||
protocol_override='sso',
|
||||
props=['--some-param=1', '--bar=2']), response)
|
||||
|
||||
@mock.patch('os.path.exists', return_value=False)
|
||||
@mock.patch('sys.stdout', StringIO())
|
||||
@@ -237,8 +237,7 @@ class TestGclientGitCheckout(unittest.TestCase):
|
||||
self.run_gclient = mock.patch('fetch.GclientCheckout.run_gclient').start()
|
||||
self.run_git = mock.patch('fetch.GitCheckout.run_git').start()
|
||||
|
||||
self.opts = argparse.Namespace(
|
||||
dry_run=False, nohooks=True, no_history=False)
|
||||
self.opts = argparse.Namespace(dry_run=False, nohooks=True, nohistory=False)
|
||||
specs = {
|
||||
'solutions': [{
|
||||
'foo': 'bar',
|
||||
|
||||
Reference in New Issue
Block a user