Commit 512dfd67 authored by Thiago Perrotta's avatar Thiago Perrotta Committed by LUCI CQ

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: 's avatarAravind Vasudevan <aravindvasudev@google.com>
parent 18bdadc9
......@@ -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',
......
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