diff --git a/fetch.py b/fetch.py index e12e7d34e..969277a28 100755 --- a/fetch.py +++ b/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( diff --git a/tests/fetch_test.py b/tests/fetch_test.py index 95d5aebcd..484863375 100755 --- a/tests/fetch_test.py +++ b/tests/fetch_test.py @@ -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',