We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Skip hook if there are no files to run for it.
This blocks adding `flake8` as a hook as it explodes when there are no files.

This will also be a bit of a performance hack.


--- 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/commands.py`
Content:
```
1 from __future__ import print_function
2 
3 import logging
4 import os
5 import pkg_resources
6 import shutil
7 import stat
8 import subprocess
9 import sys
10 from asottile.ordereddict import OrderedDict
11 from asottile.yaml import ordered_dump
12 from asottile.yaml import ordered_load
13 from plumbum import local
14 
15 import pre_commit.constants as C
16 from pre_commit import git
17 from pre_commit import color
18 from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA
19 from pre_commit.clientlib.validate_config import load_config
20 from pre_commit.jsonschema_extensions import remove_defaults
21 from pre_commit.logging_handler import LoggingHandler
22 from pre_commit.repository import Repository
23 from pre_commit.staged_files_only import staged_files_only
24 
25 
26 logger = logging.getLogger('pre_commit')
27 
28 COLS = int(subprocess.Popen(['tput', 'cols'], stdout=subprocess.PIPE).communicate()[0])
29 
30 PASS_FAIL_LENGTH = 6
31 
32 
33 def install(runner):
34     """Install the pre-commit hooks."""
35     pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
36     with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:
37         pre_commit_file_obj.write(open(pre_commit_file).read())
38 
39     original_mode = os.stat(runner.pre_commit_path).st_mode
40     os.chmod(
41         runner.pre_commit_path,
42         original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,
43     )
44 
45     print('pre-commit installed at {0}'.format(runner.pre_commit_path))
46 
47     return 0
48 
49 
50 def uninstall(runner):
51     """Uninstall the pre-commit hooks."""
52     if os.path.exists(runner.pre_commit_path):
53         os.remove(runner.pre_commit_path)
54         print('pre-commit uninstalled')
55     return 0
56 
57 
58 class RepositoryCannotBeUpdatedError(RuntimeError):
59     pass
60 
61 
62 def _update_repository(repo_config):
63     """Updates a repository to the tip of `master`.  If the repository cannot
64     be updated because a hook that is configured does not exist in `master`,
65     this raises a RepositoryCannotBeUpdatedError
66 
67     Args:
68         repo_config - A config for a repository
69     """
70     repo = Repository(repo_config)
71 
72     with repo.in_checkout():
73         local['git']['fetch']()
74         head_sha = local['git']['rev-parse', 'origin/master']().strip()
75 
76     # Don't bother trying to update if our sha is the same
77     if head_sha == repo_config['sha']:
78         return repo_config
79 
80     # Construct a new config with the head sha
81     new_config = OrderedDict(repo_config)
82     new_config['sha'] = head_sha
83     new_repo = Repository(new_config)
84 
85     # See if any of our hooks were deleted with the new commits
86     hooks = set(repo.hooks.keys())
87     hooks_missing = hooks - (hooks & set(new_repo.manifest.keys()))
88     if hooks_missing:
89         raise RepositoryCannotBeUpdatedError(
90             'Cannot update because the tip of master is missing these hooks:\n'
91             '{0}'.format(', '.join(sorted(hooks_missing)))
92         )
93 
94     return remove_defaults([new_config], CONFIG_JSON_SCHEMA)[0]
95 
96 
97 def autoupdate(runner):
98     """Auto-update the pre-commit config to the latest versions of repos."""
99     retv = 0
100     output_configs = []
101     changed = False
102 
103     input_configs = load_config(
104         runner.config_file_path,
105         load_strategy=ordered_load,
106     )
107 
108     for repo_config in input_configs:
109         print('Updating {0}...'.format(repo_config['repo']), end='')
110         try:
111             new_repo_config = _update_repository(repo_config)
112         except RepositoryCannotBeUpdatedError as error:
113             print(error.args[0])
114             output_configs.append(repo_config)
115             retv = 1
116             continue
117 
118         if new_repo_config['sha'] != repo_config['sha']:
119             changed = True
120             print(
121                 'updating {0} -> {1}.'.format(
122                     repo_config['sha'], new_repo_config['sha'],
123                 )
124             )
125             output_configs.append(new_repo_config)
126         else:
127             print('already up to date.')
128             output_configs.append(repo_config)
129 
130     if changed:
131         with open(runner.config_file_path, 'w') as config_file:
132             config_file.write(
133                 ordered_dump(output_configs, **C.YAML_DUMP_KWARGS)
134             )
135 
136     return retv
137 
138 
139 def clean(runner):
140     if os.path.exists(runner.hooks_workspace_path):
141         shutil.rmtree(runner.hooks_workspace_path)
142         print('Cleaned {0}.'.format(runner.hooks_workspace_path))
143     return 0
144 
145 
146 def _run_single_hook(runner, repository, hook_id, args, write):
147     if args.all_files:
148         get_filenames = git.get_all_files_matching
149     else:
150         get_filenames = git.get_staged_files_matching
151 
152     hook = repository.hooks[hook_id]
153 
154     # Print the hook and the dots first in case the hook takes hella long to
155     # run.
156     write(
157         '{0}{1}'.format(
158             hook['name'],
159             '.' * (COLS - len(hook['name']) - PASS_FAIL_LENGTH - 6),
160         ),
161     )
162     sys.stdout.flush()
163 
164     retcode, stdout, stderr = repository.run_hook(
165         runner.cmd_runner,
166         hook_id,
167         get_filenames(hook['files'], hook['exclude']),
168     )
169 
170     if retcode != repository.hooks[hook_id]['expected_return_value']:
171         retcode = 1
172         print_color = color.RED
173         pass_fail = 'Failed'
174     else:
175         retcode = 0
176         print_color = color.GREEN
177         pass_fail = 'Passed'
178 
179     write(color.format_color(pass_fail, print_color, args.color) + '\n')
180 
181     if (stdout or stderr) and (retcode or args.verbose):
182         write('\n')
183         for output in (stdout, stderr):
184             if output.strip():
185                 write(output.strip() + '\n')
186         write('\n')
187 
188     return retcode
189 
190 
191 def _run_hooks(runner, args, write):
192     """Actually run the hooks."""
193     retval = 0
194 
195     for repo in runner.repositories:
196         for hook_id in repo.hooks:
197             retval |= _run_single_hook(runner, repo, hook_id, args, write=write)
198 
199     return retval
200 
201 
202 def _run_hook(runner, hook_id, args, write):
203     for repo in runner.repositories:
204         if hook_id in repo.hooks:
205             return _run_single_hook(runner, repo, hook_id, args, write=write)
206     else:
207         write('No hook with id `{0}`\n'.format(hook_id))
208         return 1
209 
210 
211 def run(runner, args, write=sys.stdout.write):
212     # Set up our logging handler
213     logger.addHandler(LoggingHandler(args.color))
214     logger.setLevel(logging.INFO)
215 
216     with staged_files_only(runner.cmd_runner):
217         if args.hook:
218             return _run_hook(runner, args.hook, args, write=write)
219         else:
220             return _run_hooks(runner, args, write=write)
221
```
--- 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/commands.py b/pre_commit/commands.py
--- a/pre_commit/commands.py
+++ b/pre_commit/commands.py
@@ -151,6 +151,26 @@
 
     hook = repository.hooks[hook_id]
 
+    filenames = get_filenames(hook['files'], hook['exclude'])
+    if not filenames:
+        no_files_msg = '(no files to check) '
+        skipped_msg = 'Skipped'
+        write(
+            '{0}{1}{2}{3}\n'.format(
+                hook['name'],
+                '.' * (
+                    COLS -
+                    len(hook['name']) -
+                    len(no_files_msg) -
+                    len(skipped_msg) -
+                    6
+                ),
+                no_files_msg,
+                color.format_color(skipped_msg, color.TURQUOISE, args.color),
+            )
+        )
+        return 0
+
     # Print the hook and the dots first in case the hook takes hella long to
     # run.
     write(
@@ -164,7 +184,7 @@
     retcode, stdout, stderr = repository.run_hook(
         runner.cmd_runner,
         hook_id,
-        get_filenames(hook['files'], hook['exclude']),
+        filenames,
     )
 
     if retcode != repository.hooks[hook_id]['expected_return_value']:

{"golden_diff": "diff --git a/pre_commit/commands.py b/pre_commit/commands.py\n--- a/pre_commit/commands.py\n+++ b/pre_commit/commands.py\n@@ -151,6 +151,26 @@\n \n     hook = repository.hooks[hook_id]\n \n+    filenames = get_filenames(hook['files'], hook['exclude'])\n+    if not filenames:\n+        no_files_msg = '(no files to check) '\n+        skipped_msg = 'Skipped'\n+        write(\n+            '{0}{1}{2}{3}\\n'.format(\n+                hook['name'],\n+                '.' * (\n+                    COLS -\n+                    len(hook['name']) -\n+                    len(no_files_msg) -\n+                    len(skipped_msg) -\n+                    6\n+                ),\n+                no_files_msg,\n+                color.format_color(skipped_msg, color.TURQUOISE, args.color),\n+            )\n+        )\n+        return 0\n+\n     # Print the hook and the dots first in case the hook takes hella long to\n     # run.\n     write(\n@@ -164,7 +184,7 @@\n     retcode, stdout, stderr = repository.run_hook(\n         runner.cmd_runner,\n         hook_id,\n-        get_filenames(hook['files'], hook['exclude']),\n+        filenames,\n     )\n \n     if retcode != repository.hooks[hook_id]['expected_return_value']:\n", "issue": "Skip hook if there are no files to run for it.\nThis blocks adding `flake8` as a hook as it explodes when there are no files.\n\nThis will also be a bit of a performance hack.\n\n", "before_files": [{"content": "from __future__ import print_function\n\nimport logging\nimport os\nimport pkg_resources\nimport shutil\nimport stat\nimport subprocess\nimport sys\nfrom asottile.ordereddict import OrderedDict\nfrom asottile.yaml import ordered_dump\nfrom asottile.yaml import ordered_load\nfrom plumbum import local\n\nimport pre_commit.constants as C\nfrom pre_commit import git\nfrom pre_commit import color\nfrom pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA\nfrom pre_commit.clientlib.validate_config import load_config\nfrom pre_commit.jsonschema_extensions import remove_defaults\nfrom pre_commit.logging_handler import LoggingHandler\nfrom pre_commit.repository import Repository\nfrom pre_commit.staged_files_only import staged_files_only\n\n\nlogger = logging.getLogger('pre_commit')\n\nCOLS = int(subprocess.Popen(['tput', 'cols'], stdout=subprocess.PIPE).communicate()[0])\n\nPASS_FAIL_LENGTH = 6\n\n\ndef install(runner):\n    \"\"\"Install the pre-commit hooks.\"\"\"\n    pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n    with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:\n        pre_commit_file_obj.write(open(pre_commit_file).read())\n\n    original_mode = os.stat(runner.pre_commit_path).st_mode\n    os.chmod(\n        runner.pre_commit_path,\n        original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,\n    )\n\n    print('pre-commit installed at {0}'.format(runner.pre_commit_path))\n\n    return 0\n\n\ndef uninstall(runner):\n    \"\"\"Uninstall the pre-commit hooks.\"\"\"\n    if os.path.exists(runner.pre_commit_path):\n        os.remove(runner.pre_commit_path)\n        print('pre-commit uninstalled')\n    return 0\n\n\nclass RepositoryCannotBeUpdatedError(RuntimeError):\n    pass\n\n\ndef _update_repository(repo_config):\n    \"\"\"Updates a repository to the tip of `master`.  If the repository cannot\n    be updated because a hook that is configured does not exist in `master`,\n    this raises a RepositoryCannotBeUpdatedError\n\n    Args:\n        repo_config - A config for a repository\n    \"\"\"\n    repo = Repository(repo_config)\n\n    with repo.in_checkout():\n        local['git']['fetch']()\n        head_sha = local['git']['rev-parse', 'origin/master']().strip()\n\n    # Don't bother trying to update if our sha is the same\n    if head_sha == repo_config['sha']:\n        return repo_config\n\n    # Construct a new config with the head sha\n    new_config = OrderedDict(repo_config)\n    new_config['sha'] = head_sha\n    new_repo = Repository(new_config)\n\n    # See if any of our hooks were deleted with the new commits\n    hooks = set(repo.hooks.keys())\n    hooks_missing = hooks - (hooks & set(new_repo.manifest.keys()))\n    if hooks_missing:\n        raise RepositoryCannotBeUpdatedError(\n            'Cannot update because the tip of master is missing these hooks:\\n'\n            '{0}'.format(', '.join(sorted(hooks_missing)))\n        )\n\n    return remove_defaults([new_config], CONFIG_JSON_SCHEMA)[0]\n\n\ndef autoupdate(runner):\n    \"\"\"Auto-update the pre-commit config to the latest versions of repos.\"\"\"\n    retv = 0\n    output_configs = []\n    changed = False\n\n    input_configs = load_config(\n        runner.config_file_path,\n        load_strategy=ordered_load,\n    )\n\n    for repo_config in input_configs:\n        print('Updating {0}...'.format(repo_config['repo']), end='')\n        try:\n            new_repo_config = _update_repository(repo_config)\n        except RepositoryCannotBeUpdatedError as error:\n            print(error.args[0])\n            output_configs.append(repo_config)\n            retv = 1\n            continue\n\n        if new_repo_config['sha'] != repo_config['sha']:\n            changed = True\n            print(\n                'updating {0} -> {1}.'.format(\n                    repo_config['sha'], new_repo_config['sha'],\n                )\n            )\n            output_configs.append(new_repo_config)\n        else:\n            print('already up to date.')\n            output_configs.append(repo_config)\n\n    if changed:\n        with open(runner.config_file_path, 'w') as config_file:\n            config_file.write(\n                ordered_dump(output_configs, **C.YAML_DUMP_KWARGS)\n            )\n\n    return retv\n\n\ndef clean(runner):\n    if os.path.exists(runner.hooks_workspace_path):\n        shutil.rmtree(runner.hooks_workspace_path)\n        print('Cleaned {0}.'.format(runner.hooks_workspace_path))\n    return 0\n\n\ndef _run_single_hook(runner, repository, hook_id, args, write):\n    if args.all_files:\n        get_filenames = git.get_all_files_matching\n    else:\n        get_filenames = git.get_staged_files_matching\n\n    hook = repository.hooks[hook_id]\n\n    # Print the hook and the dots first in case the hook takes hella long to\n    # run.\n    write(\n        '{0}{1}'.format(\n            hook['name'],\n            '.' * (COLS - len(hook['name']) - PASS_FAIL_LENGTH - 6),\n        ),\n    )\n    sys.stdout.flush()\n\n    retcode, stdout, stderr = repository.run_hook(\n        runner.cmd_runner,\n        hook_id,\n        get_filenames(hook['files'], hook['exclude']),\n    )\n\n    if retcode != repository.hooks[hook_id]['expected_return_value']:\n        retcode = 1\n        print_color = color.RED\n        pass_fail = 'Failed'\n    else:\n        retcode = 0\n        print_color = color.GREEN\n        pass_fail = 'Passed'\n\n    write(color.format_color(pass_fail, print_color, args.color) + '\\n')\n\n    if (stdout or stderr) and (retcode or args.verbose):\n        write('\\n')\n        for output in (stdout, stderr):\n            if output.strip():\n                write(output.strip() + '\\n')\n        write('\\n')\n\n    return retcode\n\n\ndef _run_hooks(runner, args, write):\n    \"\"\"Actually run the hooks.\"\"\"\n    retval = 0\n\n    for repo in runner.repositories:\n        for hook_id in repo.hooks:\n            retval |= _run_single_hook(runner, repo, hook_id, args, write=write)\n\n    return retval\n\n\ndef _run_hook(runner, hook_id, args, write):\n    for repo in runner.repositories:\n        if hook_id in repo.hooks:\n            return _run_single_hook(runner, repo, hook_id, args, write=write)\n    else:\n        write('No hook with id `{0}`\\n'.format(hook_id))\n        return 1\n\n\ndef run(runner, args, write=sys.stdout.write):\n    # Set up our logging handler\n    logger.addHandler(LoggingHandler(args.color))\n    logger.setLevel(logging.INFO)\n\n    with staged_files_only(runner.cmd_runner):\n        if args.hook:\n            return _run_hook(runner, args.hook, args, write=write)\n        else:\n            return _run_hooks(runner, args, write=write)\n", "path": "pre_commit/commands.py"}], "after_files": [{"content": "from __future__ import print_function\n\nimport logging\nimport os\nimport pkg_resources\nimport shutil\nimport stat\nimport subprocess\nimport sys\nfrom asottile.ordereddict import OrderedDict\nfrom asottile.yaml import ordered_dump\nfrom asottile.yaml import ordered_load\nfrom plumbum import local\n\nimport pre_commit.constants as C\nfrom pre_commit import git\nfrom pre_commit import color\nfrom pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA\nfrom pre_commit.clientlib.validate_config import load_config\nfrom pre_commit.jsonschema_extensions import remove_defaults\nfrom pre_commit.logging_handler import LoggingHandler\nfrom pre_commit.repository import Repository\nfrom pre_commit.staged_files_only import staged_files_only\n\n\nlogger = logging.getLogger('pre_commit')\n\nCOLS = int(subprocess.Popen(['tput', 'cols'], stdout=subprocess.PIPE).communicate()[0])\n\nPASS_FAIL_LENGTH = 6\n\n\ndef install(runner):\n    \"\"\"Install the pre-commit hooks.\"\"\"\n    pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n    with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:\n        pre_commit_file_obj.write(open(pre_commit_file).read())\n\n    original_mode = os.stat(runner.pre_commit_path).st_mode\n    os.chmod(\n        runner.pre_commit_path,\n        original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,\n    )\n\n    print('pre-commit installed at {0}'.format(runner.pre_commit_path))\n\n    return 0\n\n\ndef uninstall(runner):\n    \"\"\"Uninstall the pre-commit hooks.\"\"\"\n    if os.path.exists(runner.pre_commit_path):\n        os.remove(runner.pre_commit_path)\n        print('pre-commit uninstalled')\n    return 0\n\n\nclass RepositoryCannotBeUpdatedError(RuntimeError):\n    pass\n\n\ndef _update_repository(repo_config):\n    \"\"\"Updates a repository to the tip of `master`.  If the repository cannot\n    be updated because a hook that is configured does not exist in `master`,\n    this raises a RepositoryCannotBeUpdatedError\n\n    Args:\n        repo_config - A config for a repository\n    \"\"\"\n    repo = Repository(repo_config)\n\n    with repo.in_checkout():\n        local['git']['fetch']()\n        head_sha = local['git']['rev-parse', 'origin/master']().strip()\n\n    # Don't bother trying to update if our sha is the same\n    if head_sha == repo_config['sha']:\n        return repo_config\n\n    # Construct a new config with the head sha\n    new_config = OrderedDict(repo_config)\n    new_config['sha'] = head_sha\n    new_repo = Repository(new_config)\n\n    # See if any of our hooks were deleted with the new commits\n    hooks = set(repo.hooks.keys())\n    hooks_missing = hooks - (hooks & set(new_repo.manifest.keys()))\n    if hooks_missing:\n        raise RepositoryCannotBeUpdatedError(\n            'Cannot update because the tip of master is missing these hooks:\\n'\n            '{0}'.format(', '.join(sorted(hooks_missing)))\n        )\n\n    return remove_defaults([new_config], CONFIG_JSON_SCHEMA)[0]\n\n\ndef autoupdate(runner):\n    \"\"\"Auto-update the pre-commit config to the latest versions of repos.\"\"\"\n    retv = 0\n    output_configs = []\n    changed = False\n\n    input_configs = load_config(\n        runner.config_file_path,\n        load_strategy=ordered_load,\n    )\n\n    for repo_config in input_configs:\n        print('Updating {0}...'.format(repo_config['repo']), end='')\n        try:\n            new_repo_config = _update_repository(repo_config)\n        except RepositoryCannotBeUpdatedError as error:\n            print(error.args[0])\n            output_configs.append(repo_config)\n            retv = 1\n            continue\n\n        if new_repo_config['sha'] != repo_config['sha']:\n            changed = True\n            print(\n                'updating {0} -> {1}.'.format(\n                    repo_config['sha'], new_repo_config['sha'],\n                )\n            )\n            output_configs.append(new_repo_config)\n        else:\n            print('already up to date.')\n            output_configs.append(repo_config)\n\n    if changed:\n        with open(runner.config_file_path, 'w') as config_file:\n            config_file.write(\n                ordered_dump(output_configs, **C.YAML_DUMP_KWARGS)\n            )\n\n    return retv\n\n\ndef clean(runner):\n    if os.path.exists(runner.hooks_workspace_path):\n        shutil.rmtree(runner.hooks_workspace_path)\n        print('Cleaned {0}.'.format(runner.hooks_workspace_path))\n    return 0\n\n\ndef _run_single_hook(runner, repository, hook_id, args, write):\n    if args.all_files:\n        get_filenames = git.get_all_files_matching\n    else:\n        get_filenames = git.get_staged_files_matching\n\n    hook = repository.hooks[hook_id]\n\n    filenames = get_filenames(hook['files'], hook['exclude'])\n    if not filenames:\n        no_files_msg = '(no files to check) '\n        skipped_msg = 'Skipped'\n        write(\n            '{0}{1}{2}{3}\\n'.format(\n                hook['name'],\n                '.' * (\n                    COLS -\n                    len(hook['name']) -\n                    len(no_files_msg) -\n                    len(skipped_msg) -\n                    6\n                ),\n                no_files_msg,\n                color.format_color(skipped_msg, color.TURQUOISE, args.color),\n            )\n        )\n        return 0\n\n    # Print the hook and the dots first in case the hook takes hella long to\n    # run.\n    write(\n        '{0}{1}'.format(\n            hook['name'],\n            '.' * (COLS - len(hook['name']) - PASS_FAIL_LENGTH - 6),\n        ),\n    )\n    sys.stdout.flush()\n\n    retcode, stdout, stderr = repository.run_hook(\n        runner.cmd_runner,\n        hook_id,\n        filenames,\n    )\n\n    if retcode != repository.hooks[hook_id]['expected_return_value']:\n        retcode = 1\n        print_color = color.RED\n        pass_fail = 'Failed'\n    else:\n        retcode = 0\n        print_color = color.GREEN\n        pass_fail = 'Passed'\n\n    write(color.format_color(pass_fail, print_color, args.color) + '\\n')\n\n    if (stdout or stderr) and (retcode or args.verbose):\n        write('\\n')\n        for output in (stdout, stderr):\n            if output.strip():\n                write(output.strip() + '\\n')\n        write('\\n')\n\n    return retcode\n\n\ndef _run_hooks(runner, args, write):\n    \"\"\"Actually run the hooks.\"\"\"\n    retval = 0\n\n    for repo in runner.repositories:\n        for hook_id in repo.hooks:\n            retval |= _run_single_hook(runner, repo, hook_id, args, write=write)\n\n    return retval\n\n\ndef _run_hook(runner, hook_id, args, write):\n    for repo in runner.repositories:\n        if hook_id in repo.hooks:\n            return _run_single_hook(runner, repo, hook_id, args, write=write)\n    else:\n        write('No hook with id `{0}`\\n'.format(hook_id))\n        return 1\n\n\ndef run(runner, args, write=sys.stdout.write):\n    # Set up our logging handler\n    logger.addHandler(LoggingHandler(args.color))\n    logger.setLevel(logging.INFO)\n\n    with staged_files_only(runner.cmd_runner):\n        if args.hook:\n            return _run_hook(runner, args.hook, args, write=write)\n        else:\n            return _run_hooks(runner, args, write=write)\n", "path": "pre_commit/commands.py"}]}