We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[RFC] Make the default of `pre-commit autoupdate` use `--tags-only`?
I find that `--tags-only` to be much better than the default.

My proposal:

- Make the `--tags-only` behaviour the default behaviour
- Make `--tags-only` a noop argument which produces a warning and does the default
- Add a `--bleeding-edge` which does the current default behaviour

@chriskuehl  thoughts?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pre_commit/main.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import argparse
4 import os
5 import sys
6 
7 import pre_commit.constants as C
8 from pre_commit import color
9 from pre_commit import five
10 from pre_commit import git
11 from pre_commit.commands.autoupdate import autoupdate
12 from pre_commit.commands.clean import clean
13 from pre_commit.commands.install_uninstall import install
14 from pre_commit.commands.install_uninstall import install_hooks
15 from pre_commit.commands.install_uninstall import uninstall
16 from pre_commit.commands.run import run
17 from pre_commit.commands.sample_config import sample_config
18 from pre_commit.error_handler import error_handler
19 from pre_commit.logging_handler import add_logging_handler
20 from pre_commit.runner import Runner
21 
22 
23 # https://github.com/pre-commit/pre-commit/issues/217
24 # On OSX, making a virtualenv using pyvenv at . causes `virtualenv` and `pip`
25 # to install packages to the wrong place.  We don't want anything to deal with
26 # pyvenv
27 os.environ.pop('__PYVENV_LAUNCHER__', None)
28 
29 
30 def _add_color_option(parser):
31     parser.add_argument(
32         '--color', default='auto', type=color.use_color,
33         metavar='{' + ','.join(color.COLOR_CHOICES) + '}',
34         help='Whether to use color in output.  Defaults to `%(default)s`.',
35     )
36 
37 
38 def _add_config_option(parser):
39     parser.add_argument(
40         '-c', '--config', default='.pre-commit-config.yaml',
41         help='Path to alternate config file'
42     )
43 
44 
45 def main(argv=None):
46     argv = argv if argv is not None else sys.argv[1:]
47     argv = [five.to_text(arg) for arg in argv]
48     parser = argparse.ArgumentParser()
49 
50     # http://stackoverflow.com/a/8521644/812183
51     parser.add_argument(
52         '-V', '--version',
53         action='version',
54         version='%(prog)s {}'.format(C.VERSION),
55     )
56 
57     subparsers = parser.add_subparsers(dest='command')
58 
59     install_parser = subparsers.add_parser(
60         'install', help='Install the pre-commit script.',
61     )
62     _add_color_option(install_parser)
63     _add_config_option(install_parser)
64     install_parser.add_argument(
65         '-f', '--overwrite', action='store_true',
66         help='Overwrite existing hooks / remove migration mode.',
67     )
68     install_parser.add_argument(
69         '--install-hooks', action='store_true',
70         help=(
71             'Whether to install hook environments for all environments '
72             'in the config file.'
73         ),
74     )
75     install_parser.add_argument(
76         '-t', '--hook-type', choices=('pre-commit', 'pre-push'),
77         default='pre-commit',
78     )
79     install_parser.add_argument(
80         '--allow-missing-config', action='store_true', default=False,
81         help=(
82             'Whether to allow a missing `pre-config` configuration file '
83             'or exit with a failure code.'
84         ),
85     )
86 
87     install_hooks_parser = subparsers.add_parser(
88         'install-hooks',
89         help=(
90             'Install hook environments for all environments in the config '
91             'file.  You may find `pre-commit install --install-hooks` more '
92             'useful.'
93         ),
94     )
95     _add_color_option(install_hooks_parser)
96     _add_config_option(install_hooks_parser)
97 
98     uninstall_parser = subparsers.add_parser(
99         'uninstall', help='Uninstall the pre-commit script.',
100     )
101     _add_color_option(uninstall_parser)
102     _add_config_option(uninstall_parser)
103     uninstall_parser.add_argument(
104         '-t', '--hook-type', choices=('pre-commit', 'pre-push'),
105         default='pre-commit',
106     )
107 
108     clean_parser = subparsers.add_parser(
109         'clean', help='Clean out pre-commit files.',
110     )
111     _add_color_option(clean_parser)
112     _add_config_option(clean_parser)
113     autoupdate_parser = subparsers.add_parser(
114         'autoupdate',
115         help="Auto-update pre-commit config to the latest repos' versions.",
116     )
117     _add_color_option(autoupdate_parser)
118     _add_config_option(autoupdate_parser)
119     autoupdate_parser.add_argument(
120         '--tags-only', action='store_true', help='Update to tags only.',
121     )
122 
123     run_parser = subparsers.add_parser('run', help='Run hooks.')
124     _add_color_option(run_parser)
125     _add_config_option(run_parser)
126     run_parser.add_argument('hook', nargs='?', help='A single hook-id to run')
127     run_parser.add_argument(
128         '--no-stash', default=False, action='store_true',
129         help='Use this option to prevent auto stashing of unstaged files.',
130     )
131     run_parser.add_argument(
132         '--verbose', '-v', action='store_true', default=False,
133     )
134     run_parser.add_argument(
135         '--origin', '-o',
136         help="The origin branch's commit_id when using `git push`.",
137     )
138     run_parser.add_argument(
139         '--source', '-s',
140         help="The remote branch's commit_id when using `git push`.",
141     )
142     run_parser.add_argument(
143         '--allow-unstaged-config', default=False, action='store_true',
144         help=(
145             'Allow an unstaged config to be present.  Note that this will '
146             'be stashed before parsing unless --no-stash is specified.'
147         ),
148     )
149     run_parser.add_argument(
150         '--hook-stage', choices=('commit', 'push'), default='commit',
151         help='The stage during which the hook is fired e.g. commit or push.',
152     )
153     run_parser.add_argument(
154         '--show-diff-on-failure', action='store_true',
155         help='When hooks fail, run `git diff` directly afterward.',
156     )
157     run_mutex_group = run_parser.add_mutually_exclusive_group(required=False)
158     run_mutex_group.add_argument(
159         '--all-files', '-a', action='store_true', default=False,
160         help='Run on all the files in the repo.  Implies --no-stash.',
161     )
162     run_mutex_group.add_argument(
163         '--files', nargs='*', default=[],
164         help='Specific filenames to run hooks on.',
165     )
166 
167     sample_config_parser = subparsers.add_parser(
168         'sample-config', help='Produce a sample {} file'.format(C.CONFIG_FILE),
169     )
170     _add_color_option(sample_config_parser)
171     _add_config_option(sample_config_parser)
172 
173     help = subparsers.add_parser(
174         'help', help='Show help for a specific command.',
175     )
176     help.add_argument('help_cmd', nargs='?', help='Command to show help for.')
177 
178     # Argparse doesn't really provide a way to use a `default` subparser
179     if len(argv) == 0:
180         argv = ['run']
181     args = parser.parse_args(argv)
182     if args.command == 'run':
183         args.files = [
184             os.path.relpath(os.path.abspath(filename), git.get_root())
185             for filename in args.files
186         ]
187 
188     if args.command == 'help':
189         if args.help_cmd:
190             parser.parse_args([args.help_cmd, '--help'])
191         else:
192             parser.parse_args(['--help'])
193 
194     with error_handler():
195         add_logging_handler(args.color)
196         runner = Runner.create(args.config)
197         git.check_for_cygwin_mismatch()
198 
199         if args.command == 'install':
200             return install(
201                 runner, overwrite=args.overwrite, hooks=args.install_hooks,
202                 hook_type=args.hook_type,
203                 skip_on_missing_conf=args.allow_missing_config,
204             )
205         elif args.command == 'install-hooks':
206             return install_hooks(runner)
207         elif args.command == 'uninstall':
208             return uninstall(runner, hook_type=args.hook_type)
209         elif args.command == 'clean':
210             return clean(runner)
211         elif args.command == 'autoupdate':
212             return autoupdate(runner, args.tags_only)
213         elif args.command == 'run':
214             return run(runner, args)
215         elif args.command == 'sample-config':
216             return sample_config()
217         else:
218             raise NotImplementedError(
219                 'Command {} not implemented.'.format(args.command)
220             )
221 
222         raise AssertionError(
223             'Command {} failed to exit with a returncode'.format(args.command)
224         )
225 
226 
227 if __name__ == '__main__':
228     exit(main())
229
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pre_commit/main.py b/pre_commit/main.py
--- a/pre_commit/main.py
+++ b/pre_commit/main.py
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 import argparse
+import logging
 import os
 import sys
 
@@ -20,6 +21,8 @@
 from pre_commit.runner import Runner
 
 
+logger = logging.getLogger('pre_commit')
+
 # https://github.com/pre-commit/pre-commit/issues/217
 # On OSX, making a virtualenv using pyvenv at . causes `virtualenv` and `pip`
 # to install packages to the wrong place.  We don't want anything to deal with
@@ -117,7 +120,14 @@
     _add_color_option(autoupdate_parser)
     _add_config_option(autoupdate_parser)
     autoupdate_parser.add_argument(
-        '--tags-only', action='store_true', help='Update to tags only.',
+        '--tags-only', action='store_true', help='LEGACY: for compatibility',
+    )
+    autoupdate_parser.add_argument(
+        '--bleeding-edge', action='store_true',
+        help=(
+            'Update to the bleeding edge of `master` instead of the latest '
+            'tagged version (the default behavior).'
+        ),
     )
 
     run_parser = subparsers.add_parser('run', help='Run hooks.')
@@ -209,7 +219,9 @@
         elif args.command == 'clean':
             return clean(runner)
         elif args.command == 'autoupdate':
-            return autoupdate(runner, args.tags_only)
+            if args.tags_only:
+                logger.warning('--tags-only is the default')
+            return autoupdate(runner, tags_only=not args.bleeding_edge)
         elif args.command == 'run':
             return run(runner, args)
         elif args.command == 'sample-config':

{"golden_diff": "diff --git a/pre_commit/main.py b/pre_commit/main.py\n--- a/pre_commit/main.py\n+++ b/pre_commit/main.py\n@@ -1,6 +1,7 @@\n from __future__ import unicode_literals\n \n import argparse\n+import logging\n import os\n import sys\n \n@@ -20,6 +21,8 @@\n from pre_commit.runner import Runner\n \n \n+logger = logging.getLogger('pre_commit')\n+\n # https://github.com/pre-commit/pre-commit/issues/217\n # On OSX, making a virtualenv using pyvenv at . causes `virtualenv` and `pip`\n # to install packages to the wrong place.  We don't want anything to deal with\n@@ -117,7 +120,14 @@\n     _add_color_option(autoupdate_parser)\n     _add_config_option(autoupdate_parser)\n     autoupdate_parser.add_argument(\n-        '--tags-only', action='store_true', help='Update to tags only.',\n+        '--tags-only', action='store_true', help='LEGACY: for compatibility',\n+    )\n+    autoupdate_parser.add_argument(\n+        '--bleeding-edge', action='store_true',\n+        help=(\n+            'Update to the bleeding edge of `master` instead of the latest '\n+            'tagged version (the default behavior).'\n+        ),\n     )\n \n     run_parser = subparsers.add_parser('run', help='Run hooks.')\n@@ -209,7 +219,9 @@\n         elif args.command == 'clean':\n             return clean(runner)\n         elif args.command == 'autoupdate':\n-            return autoupdate(runner, args.tags_only)\n+            if args.tags_only:\n+                logger.warning('--tags-only is the default')\n+            return autoupdate(runner, tags_only=not args.bleeding_edge)\n         elif args.command == 'run':\n             return run(runner, args)\n         elif args.command == 'sample-config':\n", "issue": "[RFC] Make the default of `pre-commit autoupdate` use `--tags-only`?\nI find that `--tags-only` to be much better than the default.\r\n\r\nMy proposal:\r\n\r\n- Make the `--tags-only` behaviour the default behaviour\r\n- Make `--tags-only` a noop argument which produces a warning and does the default\r\n- Add a `--bleeding-edge` which does the current default behaviour\r\n\r\n@chriskuehl  thoughts?\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport argparse\nimport os\nimport sys\n\nimport pre_commit.constants as C\nfrom pre_commit import color\nfrom pre_commit import five\nfrom pre_commit import git\nfrom pre_commit.commands.autoupdate import autoupdate\nfrom pre_commit.commands.clean import clean\nfrom pre_commit.commands.install_uninstall import install\nfrom pre_commit.commands.install_uninstall import install_hooks\nfrom pre_commit.commands.install_uninstall import uninstall\nfrom pre_commit.commands.run import run\nfrom pre_commit.commands.sample_config import sample_config\nfrom pre_commit.error_handler import error_handler\nfrom pre_commit.logging_handler import add_logging_handler\nfrom pre_commit.runner import Runner\n\n\n# https://github.com/pre-commit/pre-commit/issues/217\n# On OSX, making a virtualenv using pyvenv at . causes `virtualenv` and `pip`\n# to install packages to the wrong place.  We don't want anything to deal with\n# pyvenv\nos.environ.pop('__PYVENV_LAUNCHER__', None)\n\n\ndef _add_color_option(parser):\n    parser.add_argument(\n        '--color', default='auto', type=color.use_color,\n        metavar='{' + ','.join(color.COLOR_CHOICES) + '}',\n        help='Whether to use color in output.  Defaults to `%(default)s`.',\n    )\n\n\ndef _add_config_option(parser):\n    parser.add_argument(\n        '-c', '--config', default='.pre-commit-config.yaml',\n        help='Path to alternate config file'\n    )\n\n\ndef main(argv=None):\n    argv = argv if argv is not None else sys.argv[1:]\n    argv = [five.to_text(arg) for arg in argv]\n    parser = argparse.ArgumentParser()\n\n    # http://stackoverflow.com/a/8521644/812183\n    parser.add_argument(\n        '-V', '--version',\n        action='version',\n        version='%(prog)s {}'.format(C.VERSION),\n    )\n\n    subparsers = parser.add_subparsers(dest='command')\n\n    install_parser = subparsers.add_parser(\n        'install', help='Install the pre-commit script.',\n    )\n    _add_color_option(install_parser)\n    _add_config_option(install_parser)\n    install_parser.add_argument(\n        '-f', '--overwrite', action='store_true',\n        help='Overwrite existing hooks / remove migration mode.',\n    )\n    install_parser.add_argument(\n        '--install-hooks', action='store_true',\n        help=(\n            'Whether to install hook environments for all environments '\n            'in the config file.'\n        ),\n    )\n    install_parser.add_argument(\n        '-t', '--hook-type', choices=('pre-commit', 'pre-push'),\n        default='pre-commit',\n    )\n    install_parser.add_argument(\n        '--allow-missing-config', action='store_true', default=False,\n        help=(\n            'Whether to allow a missing `pre-config` configuration file '\n            'or exit with a failure code.'\n        ),\n    )\n\n    install_hooks_parser = subparsers.add_parser(\n        'install-hooks',\n        help=(\n            'Install hook environments for all environments in the config '\n            'file.  You may find `pre-commit install --install-hooks` more '\n            'useful.'\n        ),\n    )\n    _add_color_option(install_hooks_parser)\n    _add_config_option(install_hooks_parser)\n\n    uninstall_parser = subparsers.add_parser(\n        'uninstall', help='Uninstall the pre-commit script.',\n    )\n    _add_color_option(uninstall_parser)\n    _add_config_option(uninstall_parser)\n    uninstall_parser.add_argument(\n        '-t', '--hook-type', choices=('pre-commit', 'pre-push'),\n        default='pre-commit',\n    )\n\n    clean_parser = subparsers.add_parser(\n        'clean', help='Clean out pre-commit files.',\n    )\n    _add_color_option(clean_parser)\n    _add_config_option(clean_parser)\n    autoupdate_parser = subparsers.add_parser(\n        'autoupdate',\n        help=\"Auto-update pre-commit config to the latest repos' versions.\",\n    )\n    _add_color_option(autoupdate_parser)\n    _add_config_option(autoupdate_parser)\n    autoupdate_parser.add_argument(\n        '--tags-only', action='store_true', help='Update to tags only.',\n    )\n\n    run_parser = subparsers.add_parser('run', help='Run hooks.')\n    _add_color_option(run_parser)\n    _add_config_option(run_parser)\n    run_parser.add_argument('hook', nargs='?', help='A single hook-id to run')\n    run_parser.add_argument(\n        '--no-stash', default=False, action='store_true',\n        help='Use this option to prevent auto stashing of unstaged files.',\n    )\n    run_parser.add_argument(\n        '--verbose', '-v', action='store_true', default=False,\n    )\n    run_parser.add_argument(\n        '--origin', '-o',\n        help=\"The origin branch's commit_id when using `git push`.\",\n    )\n    run_parser.add_argument(\n        '--source', '-s',\n        help=\"The remote branch's commit_id when using `git push`.\",\n    )\n    run_parser.add_argument(\n        '--allow-unstaged-config', default=False, action='store_true',\n        help=(\n            'Allow an unstaged config to be present.  Note that this will '\n            'be stashed before parsing unless --no-stash is specified.'\n        ),\n    )\n    run_parser.add_argument(\n        '--hook-stage', choices=('commit', 'push'), default='commit',\n        help='The stage during which the hook is fired e.g. commit or push.',\n    )\n    run_parser.add_argument(\n        '--show-diff-on-failure', action='store_true',\n        help='When hooks fail, run `git diff` directly afterward.',\n    )\n    run_mutex_group = run_parser.add_mutually_exclusive_group(required=False)\n    run_mutex_group.add_argument(\n        '--all-files', '-a', action='store_true', default=False,\n        help='Run on all the files in the repo.  Implies --no-stash.',\n    )\n    run_mutex_group.add_argument(\n        '--files', nargs='*', default=[],\n        help='Specific filenames to run hooks on.',\n    )\n\n    sample_config_parser = subparsers.add_parser(\n        'sample-config', help='Produce a sample {} file'.format(C.CONFIG_FILE),\n    )\n    _add_color_option(sample_config_parser)\n    _add_config_option(sample_config_parser)\n\n    help = subparsers.add_parser(\n        'help', help='Show help for a specific command.',\n    )\n    help.add_argument('help_cmd', nargs='?', help='Command to show help for.')\n\n    # Argparse doesn't really provide a way to use a `default` subparser\n    if len(argv) == 0:\n        argv = ['run']\n    args = parser.parse_args(argv)\n    if args.command == 'run':\n        args.files = [\n            os.path.relpath(os.path.abspath(filename), git.get_root())\n            for filename in args.files\n        ]\n\n    if args.command == 'help':\n        if args.help_cmd:\n            parser.parse_args([args.help_cmd, '--help'])\n        else:\n            parser.parse_args(['--help'])\n\n    with error_handler():\n        add_logging_handler(args.color)\n        runner = Runner.create(args.config)\n        git.check_for_cygwin_mismatch()\n\n        if args.command == 'install':\n            return install(\n                runner, overwrite=args.overwrite, hooks=args.install_hooks,\n                hook_type=args.hook_type,\n                skip_on_missing_conf=args.allow_missing_config,\n            )\n        elif args.command == 'install-hooks':\n            return install_hooks(runner)\n        elif args.command == 'uninstall':\n            return uninstall(runner, hook_type=args.hook_type)\n        elif args.command == 'clean':\n            return clean(runner)\n        elif args.command == 'autoupdate':\n            return autoupdate(runner, args.tags_only)\n        elif args.command == 'run':\n            return run(runner, args)\n        elif args.command == 'sample-config':\n            return sample_config()\n        else:\n            raise NotImplementedError(\n                'Command {} not implemented.'.format(args.command)\n            )\n\n        raise AssertionError(\n            'Command {} failed to exit with a returncode'.format(args.command)\n        )\n\n\nif __name__ == '__main__':\n    exit(main())\n", "path": "pre_commit/main.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nimport argparse\nimport logging\nimport os\nimport sys\n\nimport pre_commit.constants as C\nfrom pre_commit import color\nfrom pre_commit import five\nfrom pre_commit import git\nfrom pre_commit.commands.autoupdate import autoupdate\nfrom pre_commit.commands.clean import clean\nfrom pre_commit.commands.install_uninstall import install\nfrom pre_commit.commands.install_uninstall import install_hooks\nfrom pre_commit.commands.install_uninstall import uninstall\nfrom pre_commit.commands.run import run\nfrom pre_commit.commands.sample_config import sample_config\nfrom pre_commit.error_handler import error_handler\nfrom pre_commit.logging_handler import add_logging_handler\nfrom pre_commit.runner import Runner\n\n\nlogger = logging.getLogger('pre_commit')\n\n# https://github.com/pre-commit/pre-commit/issues/217\n# On OSX, making a virtualenv using pyvenv at . causes `virtualenv` and `pip`\n# to install packages to the wrong place.  We don't want anything to deal with\n# pyvenv\nos.environ.pop('__PYVENV_LAUNCHER__', None)\n\n\ndef _add_color_option(parser):\n    parser.add_argument(\n        '--color', default='auto', type=color.use_color,\n        metavar='{' + ','.join(color.COLOR_CHOICES) + '}',\n        help='Whether to use color in output.  Defaults to `%(default)s`.',\n    )\n\n\ndef _add_config_option(parser):\n    parser.add_argument(\n        '-c', '--config', default='.pre-commit-config.yaml',\n        help='Path to alternate config file'\n    )\n\n\ndef main(argv=None):\n    argv = argv if argv is not None else sys.argv[1:]\n    argv = [five.to_text(arg) for arg in argv]\n    parser = argparse.ArgumentParser()\n\n    # http://stackoverflow.com/a/8521644/812183\n    parser.add_argument(\n        '-V', '--version',\n        action='version',\n        version='%(prog)s {}'.format(C.VERSION),\n    )\n\n    subparsers = parser.add_subparsers(dest='command')\n\n    install_parser = subparsers.add_parser(\n        'install', help='Install the pre-commit script.',\n    )\n    _add_color_option(install_parser)\n    _add_config_option(install_parser)\n    install_parser.add_argument(\n        '-f', '--overwrite', action='store_true',\n        help='Overwrite existing hooks / remove migration mode.',\n    )\n    install_parser.add_argument(\n        '--install-hooks', action='store_true',\n        help=(\n            'Whether to install hook environments for all environments '\n            'in the config file.'\n        ),\n    )\n    install_parser.add_argument(\n        '-t', '--hook-type', choices=('pre-commit', 'pre-push'),\n        default='pre-commit',\n    )\n    install_parser.add_argument(\n        '--allow-missing-config', action='store_true', default=False,\n        help=(\n            'Whether to allow a missing `pre-config` configuration file '\n            'or exit with a failure code.'\n        ),\n    )\n\n    install_hooks_parser = subparsers.add_parser(\n        'install-hooks',\n        help=(\n            'Install hook environments for all environments in the config '\n            'file.  You may find `pre-commit install --install-hooks` more '\n            'useful.'\n        ),\n    )\n    _add_color_option(install_hooks_parser)\n    _add_config_option(install_hooks_parser)\n\n    uninstall_parser = subparsers.add_parser(\n        'uninstall', help='Uninstall the pre-commit script.',\n    )\n    _add_color_option(uninstall_parser)\n    _add_config_option(uninstall_parser)\n    uninstall_parser.add_argument(\n        '-t', '--hook-type', choices=('pre-commit', 'pre-push'),\n        default='pre-commit',\n    )\n\n    clean_parser = subparsers.add_parser(\n        'clean', help='Clean out pre-commit files.',\n    )\n    _add_color_option(clean_parser)\n    _add_config_option(clean_parser)\n    autoupdate_parser = subparsers.add_parser(\n        'autoupdate',\n        help=\"Auto-update pre-commit config to the latest repos' versions.\",\n    )\n    _add_color_option(autoupdate_parser)\n    _add_config_option(autoupdate_parser)\n    autoupdate_parser.add_argument(\n        '--tags-only', action='store_true', help='LEGACY: for compatibility',\n    )\n    autoupdate_parser.add_argument(\n        '--bleeding-edge', action='store_true',\n        help=(\n            'Update to the bleeding edge of `master` instead of the latest '\n            'tagged version (the default behavior).'\n        ),\n    )\n\n    run_parser = subparsers.add_parser('run', help='Run hooks.')\n    _add_color_option(run_parser)\n    _add_config_option(run_parser)\n    run_parser.add_argument('hook', nargs='?', help='A single hook-id to run')\n    run_parser.add_argument(\n        '--no-stash', default=False, action='store_true',\n        help='Use this option to prevent auto stashing of unstaged files.',\n    )\n    run_parser.add_argument(\n        '--verbose', '-v', action='store_true', default=False,\n    )\n    run_parser.add_argument(\n        '--origin', '-o',\n        help=\"The origin branch's commit_id when using `git push`.\",\n    )\n    run_parser.add_argument(\n        '--source', '-s',\n        help=\"The remote branch's commit_id when using `git push`.\",\n    )\n    run_parser.add_argument(\n        '--allow-unstaged-config', default=False, action='store_true',\n        help=(\n            'Allow an unstaged config to be present.  Note that this will '\n            'be stashed before parsing unless --no-stash is specified.'\n        ),\n    )\n    run_parser.add_argument(\n        '--hook-stage', choices=('commit', 'push'), default='commit',\n        help='The stage during which the hook is fired e.g. commit or push.',\n    )\n    run_parser.add_argument(\n        '--show-diff-on-failure', action='store_true',\n        help='When hooks fail, run `git diff` directly afterward.',\n    )\n    run_mutex_group = run_parser.add_mutually_exclusive_group(required=False)\n    run_mutex_group.add_argument(\n        '--all-files', '-a', action='store_true', default=False,\n        help='Run on all the files in the repo.  Implies --no-stash.',\n    )\n    run_mutex_group.add_argument(\n        '--files', nargs='*', default=[],\n        help='Specific filenames to run hooks on.',\n    )\n\n    sample_config_parser = subparsers.add_parser(\n        'sample-config', help='Produce a sample {} file'.format(C.CONFIG_FILE),\n    )\n    _add_color_option(sample_config_parser)\n    _add_config_option(sample_config_parser)\n\n    help = subparsers.add_parser(\n        'help', help='Show help for a specific command.',\n    )\n    help.add_argument('help_cmd', nargs='?', help='Command to show help for.')\n\n    # Argparse doesn't really provide a way to use a `default` subparser\n    if len(argv) == 0:\n        argv = ['run']\n    args = parser.parse_args(argv)\n    if args.command == 'run':\n        args.files = [\n            os.path.relpath(os.path.abspath(filename), git.get_root())\n            for filename in args.files\n        ]\n\n    if args.command == 'help':\n        if args.help_cmd:\n            parser.parse_args([args.help_cmd, '--help'])\n        else:\n            parser.parse_args(['--help'])\n\n    with error_handler():\n        add_logging_handler(args.color)\n        runner = Runner.create(args.config)\n        git.check_for_cygwin_mismatch()\n\n        if args.command == 'install':\n            return install(\n                runner, overwrite=args.overwrite, hooks=args.install_hooks,\n                hook_type=args.hook_type,\n                skip_on_missing_conf=args.allow_missing_config,\n            )\n        elif args.command == 'install-hooks':\n            return install_hooks(runner)\n        elif args.command == 'uninstall':\n            return uninstall(runner, hook_type=args.hook_type)\n        elif args.command == 'clean':\n            return clean(runner)\n        elif args.command == 'autoupdate':\n            if args.tags_only:\n                logger.warning('--tags-only is the default')\n            return autoupdate(runner, tags_only=not args.bleeding_edge)\n        elif args.command == 'run':\n            return run(runner, args)\n        elif args.command == 'sample-config':\n            return sample_config()\n        else:\n            raise NotImplementedError(\n                'Command {} not implemented.'.format(args.command)\n            )\n\n        raise AssertionError(\n            'Command {} failed to exit with a returncode'.format(args.command)\n        )\n\n\nif __name__ == '__main__':\n    exit(main())\n", "path": "pre_commit/main.py"}]}