prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Handle when `core.hooksPath` is set?
  As we found in https://github.com/pre-commit/pre-commit-hooks/issues/250, pre-commit (despite being installed) will be silently skipped if `core.hooksPath` is set.
  
  A few options:
  - during `pre-commit install`, check this variable and warn
  - "" but error
  - install into the directory at `core.hooksPath` (but it may be outside the working dir? probably not the best idea to write to it)
  
  </issue>
  <code>
  [start of pre_commit/commands/install_uninstall.py]
  1 from __future__ import print_function
  2 from __future__ import unicode_literals
  3 
  4 import io
  5 import os.path
  6 import sys
  7 
  8 from pre_commit import output
  9 from pre_commit.util import make_executable
  10 from pre_commit.util import mkdirp
  11 from pre_commit.util import resource_filename
  12 
  13 
  14 # This is used to identify the hook file we install
  15 PRIOR_HASHES = (
  16     '4d9958c90bc262f47553e2c073f14cfe',
  17     'd8ee923c46731b42cd95cc869add4062',
  18     '49fd668cb42069aa1b6048464be5d395',
  19     '79f09a650522a87b0da915d0d983b2de',
  20     'e358c9dae00eac5d06b38dfdb1e33a8c',
  21 )
  22 CURRENT_HASH = '138fd403232d2ddd5efb44317e38bf03'
  23 TEMPLATE_START = '# start templated\n'
  24 TEMPLATE_END = '# end templated\n'
  25 
  26 
  27 def is_our_script(filename):
  28     if not os.path.exists(filename):
  29         return False
  30     contents = io.open(filename).read()
  31     return any(h in contents for h in (CURRENT_HASH,) + PRIOR_HASHES)
  32 
  33 
  34 def install(
  35         runner, overwrite=False, hooks=False, hook_type='pre-commit',
  36         skip_on_missing_conf=False,
  37 ):
  38     """Install the pre-commit hooks."""
  39     hook_path = runner.get_hook_path(hook_type)
  40     legacy_path = hook_path + '.legacy'
  41 
  42     mkdirp(os.path.dirname(hook_path))
  43 
  44     # If we have an existing hook, move it to pre-commit.legacy
  45     if os.path.lexists(hook_path) and not is_our_script(hook_path):
  46         os.rename(hook_path, legacy_path)
  47 
  48     # If we specify overwrite, we simply delete the legacy file
  49     if overwrite and os.path.exists(legacy_path):
  50         os.remove(legacy_path)
  51     elif os.path.exists(legacy_path):
  52         output.write_line(
  53             'Running in migration mode with existing hooks at {}\n'
  54             'Use -f to use only pre-commit.'.format(legacy_path),
  55         )
  56 
  57     params = {
  58         'CONFIG': runner.config_file,
  59         'HOOK_TYPE': hook_type,
  60         'INSTALL_PYTHON': sys.executable,
  61         'SKIP_ON_MISSING_CONFIG': skip_on_missing_conf,
  62     }
  63 
  64     with io.open(hook_path, 'w') as hook_file:
  65         with io.open(resource_filename('hook-tmpl')) as f:
  66             contents = f.read()
  67         before, rest = contents.split(TEMPLATE_START)
  68         to_template, after = rest.split(TEMPLATE_END)
  69 
  70         hook_file.write(before + TEMPLATE_START)
  71         for line in to_template.splitlines():
  72             var = line.split()[0]
  73             hook_file.write('{} = {!r}\n'.format(var, params[var]))
  74         hook_file.write(TEMPLATE_END + after)
  75     make_executable(hook_path)
  76 
  77     output.write_line('pre-commit installed at {}'.format(hook_path))
  78 
  79     # If they requested we install all of the hooks, do so.
  80     if hooks:
  81         install_hooks(runner)
  82 
  83     return 0
  84 
  85 
  86 def install_hooks(runner):
  87     for repository in runner.repositories:
  88         repository.require_installed()
  89 
  90 
  91 def uninstall(runner, hook_type='pre-commit'):
  92     """Uninstall the pre-commit hooks."""
  93     hook_path = runner.get_hook_path(hook_type)
  94     legacy_path = hook_path + '.legacy'
  95     # If our file doesn't exist or it isn't ours, gtfo.
  96     if not os.path.exists(hook_path) or not is_our_script(hook_path):
  97         return 0
  98 
  99     os.remove(hook_path)
  100     output.write_line('{} uninstalled'.format(hook_type))
  101 
  102     if os.path.exists(legacy_path):
  103         os.rename(legacy_path, hook_path)
  104         output.write_line('Restored previous hooks to {}'.format(hook_path))
  105 
  106     return 0
  107
  [end of pre_commit/commands/install_uninstall.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py
  --- a/pre_commit/commands/install_uninstall.py
  +++ b/pre_commit/commands/install_uninstall.py
  @@ -2,15 +2,19 @@
   from __future__ import unicode_literals
   
   import io
  +import logging
   import os.path
   import sys
   
   from pre_commit import output
  +from pre_commit.util import cmd_output
   from pre_commit.util import make_executable
   from pre_commit.util import mkdirp
   from pre_commit.util import resource_filename
   
   
  +logger = logging.getLogger(__name__)
  +
   # This is used to identify the hook file we install
   PRIOR_HASHES = (
       '4d9958c90bc262f47553e2c073f14cfe',
  @@ -36,6 +40,13 @@
           skip_on_missing_conf=False,
   ):
       """Install the pre-commit hooks."""
  +    if cmd_output('git', 'config', 'core.hooksPath', retcode=None)[1].strip():
  +        logger.error(
  +            'Cowardly refusing to install hooks with `core.hooksPath` set.\n'
  +            'hint: `git config --unset-all core.hooksPath`',
  +        )
  +        return 1
  +
       hook_path = runner.get_hook_path(hook_type)
       legacy_path = hook_path + '.legacy'
  
verification_info: {"golden_diff": "diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py\n--- a/pre_commit/commands/install_uninstall.py\n+++ b/pre_commit/commands/install_uninstall.py\n@@ -2,15 +2,19 @@\n from __future__ import unicode_literals\n \n import io\n+import logging\n import os.path\n import sys\n \n from pre_commit import output\n+from pre_commit.util import cmd_output\n from pre_commit.util import make_executable\n from pre_commit.util import mkdirp\n from pre_commit.util import resource_filename\n \n \n+logger = logging.getLogger(__name__)\n+\n # This is used to identify the hook file we install\n PRIOR_HASHES = (\n     '4d9958c90bc262f47553e2c073f14cfe',\n@@ -36,6 +40,13 @@\n         skip_on_missing_conf=False,\n ):\n     \"\"\"Install the pre-commit hooks.\"\"\"\n+    if cmd_output('git', 'config', 'core.hooksPath', retcode=None)[1].strip():\n+        logger.error(\n+            'Cowardly refusing to install hooks with `core.hooksPath` set.\\n'\n+            'hint: `git config --unset-all core.hooksPath`',\n+        )\n+        return 1\n+\n     hook_path = runner.get_hook_path(hook_type)\n     legacy_path = hook_path + '.legacy'\n", "issue": "Handle when `core.hooksPath` is set?\nAs we found in https://github.com/pre-commit/pre-commit-hooks/issues/250, pre-commit (despite being installed) will be silently skipped if `core.hooksPath` is set.\r\n\r\nA few options:\r\n- during `pre-commit install`, check this variable and warn\r\n- \"\" but error\r\n- install into the directory at `core.hooksPath` (but it may be outside the working dir? probably not the best idea to write to it)\n", "before_files": [{"content": "from __future__ import print_function\nfrom __future__ import unicode_literals\n\nimport io\nimport os.path\nimport sys\n\nfrom pre_commit import output\nfrom pre_commit.util import make_executable\nfrom pre_commit.util import mkdirp\nfrom pre_commit.util import resource_filename\n\n\n# This is used to identify the hook file we install\nPRIOR_HASHES = (\n    '4d9958c90bc262f47553e2c073f14cfe',\n    'd8ee923c46731b42cd95cc869add4062',\n    '49fd668cb42069aa1b6048464be5d395',\n    '79f09a650522a87b0da915d0d983b2de',\n    'e358c9dae00eac5d06b38dfdb1e33a8c',\n)\nCURRENT_HASH = '138fd403232d2ddd5efb44317e38bf03'\nTEMPLATE_START = '# start templated\\n'\nTEMPLATE_END = '# end templated\\n'\n\n\ndef is_our_script(filename):\n    if not os.path.exists(filename):\n        return False\n    contents = io.open(filename).read()\n    return any(h in contents for h in (CURRENT_HASH,) + PRIOR_HASHES)\n\n\ndef install(\n        runner, overwrite=False, hooks=False, hook_type='pre-commit',\n        skip_on_missing_conf=False,\n):\n    \"\"\"Install the pre-commit hooks.\"\"\"\n    hook_path = runner.get_hook_path(hook_type)\n    legacy_path = hook_path + '.legacy'\n\n    mkdirp(os.path.dirname(hook_path))\n\n    # If we have an existing hook, move it to pre-commit.legacy\n    if os.path.lexists(hook_path) and not is_our_script(hook_path):\n        os.rename(hook_path, legacy_path)\n\n    # If we specify overwrite, we simply delete the legacy file\n    if overwrite and os.path.exists(legacy_path):\n        os.remove(legacy_path)\n    elif os.path.exists(legacy_path):\n        output.write_line(\n            'Running in migration mode with existing hooks at {}\\n'\n            'Use -f to use only pre-commit.'.format(legacy_path),\n        )\n\n    params = {\n        'CONFIG': runner.config_file,\n        'HOOK_TYPE': hook_type,\n        'INSTALL_PYTHON': sys.executable,\n        'SKIP_ON_MISSING_CONFIG': skip_on_missing_conf,\n    }\n\n    with io.open(hook_path, 'w') as hook_file:\n        with io.open(resource_filename('hook-tmpl')) as f:\n            contents = f.read()\n        before, rest = contents.split(TEMPLATE_START)\n        to_template, after = rest.split(TEMPLATE_END)\n\n        hook_file.write(before + TEMPLATE_START)\n        for line in to_template.splitlines():\n            var = line.split()[0]\n            hook_file.write('{} = {!r}\\n'.format(var, params[var]))\n        hook_file.write(TEMPLATE_END + after)\n    make_executable(hook_path)\n\n    output.write_line('pre-commit installed at {}'.format(hook_path))\n\n    # If they requested we install all of the hooks, do so.\n    if hooks:\n        install_hooks(runner)\n\n    return 0\n\n\ndef install_hooks(runner):\n    for repository in runner.repositories:\n        repository.require_installed()\n\n\ndef uninstall(runner, hook_type='pre-commit'):\n    \"\"\"Uninstall the pre-commit hooks.\"\"\"\n    hook_path = runner.get_hook_path(hook_type)\n    legacy_path = hook_path + '.legacy'\n    # If our file doesn't exist or it isn't ours, gtfo.\n    if not os.path.exists(hook_path) or not is_our_script(hook_path):\n        return 0\n\n    os.remove(hook_path)\n    output.write_line('{} uninstalled'.format(hook_type))\n\n    if os.path.exists(legacy_path):\n        os.rename(legacy_path, hook_path)\n        output.write_line('Restored previous hooks to {}'.format(hook_path))\n\n    return 0\n", "path": "pre_commit/commands/install_uninstall.py"}]}