prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  pre-commit -i does not install the file with +x
  No executable = no run :'(
  
  
  --- 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/git.py`
  Content:
  ```
  1 import functools
  2 import os
  3 import os.path
  4 import pkg_resources
  5 import re
  6 from plumbum import local
  7 
  8 from pre_commit.util import memoize_by_cwd
  9 
  10 
  11 def _get_root_new():
  12     path = os.getcwd()
  13     while len(path) > 1:
  14         if os.path.exists(os.path.join(path, '.git')):
  15             return path
  16         else:
  17             path = os.path.normpath(os.path.join(path, '../'))
  18     raise AssertionError('called from outside of the gits')
  19 
  20 
  21 @memoize_by_cwd
  22 def get_root():
  23     return _get_root_new()
  24 
  25 
  26 @memoize_by_cwd
  27 def get_pre_commit_path():
  28     return os.path.join(get_root(), '.git/hooks/pre-commit')
  29 
  30 
  31 def create_pre_commit():
  32     path = get_pre_commit_path()
  33     pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
  34     local.path(path).write(local.path(pre_commit_file).read())
  35 
  36 
  37 def remove_pre_commit():
  38     local.path(get_pre_commit_path()).delete()
  39 
  40 
  41 def get_head_sha(git_repo_path):
  42     with local.cwd(git_repo_path):
  43         return local['git']['rev-parse', 'HEAD']().strip()
  44 
  45 
  46 @memoize_by_cwd
  47 def get_staged_files():
  48     return local['git']['diff', '--staged', '--name-only']().splitlines()
  49 
  50 
  51 @memoize_by_cwd
  52 def get_all_files():
  53     return local['git']['ls-files']().splitlines()
  54 
  55 
  56 def get_files_matching(all_file_list_strategy):
  57     @functools.wraps(all_file_list_strategy)
  58     @memoize_by_cwd
  59     def wrapper(expr):
  60         regex = re.compile(expr)
  61         return set(filter(os.path.exists, (
  62             filename
  63             for filename in all_file_list_strategy()
  64             if regex.search(filename)
  65         )))
  66     return wrapper
  67 
  68 
  69 get_staged_files_matching = get_files_matching(get_staged_files)
  70 get_all_files_matching = get_files_matching(get_all_files)
  71
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/pre_commit/git.py b/pre_commit/git.py
  --- a/pre_commit/git.py
  +++ b/pre_commit/git.py
  @@ -3,6 +3,7 @@
   import os.path
   import pkg_resources
   import re
  +import stat
   from plumbum import local
   
   from pre_commit.util import memoize_by_cwd
  @@ -32,6 +33,8 @@
       path = get_pre_commit_path()
       pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
       local.path(path).write(local.path(pre_commit_file).read())
  +    original_mode = os.stat(path).st_mode
  +    os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
   
   
   def remove_pre_commit():
  
verification_info: {"golden_diff": "diff --git a/pre_commit/git.py b/pre_commit/git.py\n--- a/pre_commit/git.py\n+++ b/pre_commit/git.py\n@@ -3,6 +3,7 @@\n import os.path\n import pkg_resources\n import re\n+import stat\n from plumbum import local\n \n from pre_commit.util import memoize_by_cwd\n@@ -32,6 +33,8 @@\n     path = get_pre_commit_path()\n     pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n     local.path(path).write(local.path(pre_commit_file).read())\n+    original_mode = os.stat(path).st_mode\n+    os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n \n \n def remove_pre_commit():\n", "issue": "pre-commit -i does not install the file with +x\nNo executable = no run :'(\n\n", "before_files": [{"content": "import functools\nimport os\nimport os.path\nimport pkg_resources\nimport re\nfrom plumbum import local\n\nfrom pre_commit.util import memoize_by_cwd\n\n\ndef _get_root_new():\n    path = os.getcwd()\n    while len(path) > 1:\n        if os.path.exists(os.path.join(path, '.git')):\n            return path\n        else:\n            path = os.path.normpath(os.path.join(path, '../'))\n    raise AssertionError('called from outside of the gits')\n\n\n@memoize_by_cwd\ndef get_root():\n    return _get_root_new()\n\n\n@memoize_by_cwd\ndef get_pre_commit_path():\n    return os.path.join(get_root(), '.git/hooks/pre-commit')\n\n\ndef create_pre_commit():\n    path = get_pre_commit_path()\n    pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n    local.path(path).write(local.path(pre_commit_file).read())\n\n\ndef remove_pre_commit():\n    local.path(get_pre_commit_path()).delete()\n\n\ndef get_head_sha(git_repo_path):\n    with local.cwd(git_repo_path):\n        return local['git']['rev-parse', 'HEAD']().strip()\n\n\n@memoize_by_cwd\ndef get_staged_files():\n    return local['git']['diff', '--staged', '--name-only']().splitlines()\n\n\n@memoize_by_cwd\ndef get_all_files():\n    return local['git']['ls-files']().splitlines()\n\n\ndef get_files_matching(all_file_list_strategy):\n    @functools.wraps(all_file_list_strategy)\n    @memoize_by_cwd\n    def wrapper(expr):\n        regex = re.compile(expr)\n        return set(filter(os.path.exists, (\n            filename\n            for filename in all_file_list_strategy()\n            if regex.search(filename)\n        )))\n    return wrapper\n\n\nget_staged_files_matching = get_files_matching(get_staged_files)\nget_all_files_matching = get_files_matching(get_all_files)\n", "path": "pre_commit/git.py"}], "after_files": [{"content": "import functools\nimport os\nimport os.path\nimport pkg_resources\nimport re\nimport stat\nfrom plumbum import local\n\nfrom pre_commit.util import memoize_by_cwd\n\n\ndef _get_root_new():\n    path = os.getcwd()\n    while len(path) > 1:\n        if os.path.exists(os.path.join(path, '.git')):\n            return path\n        else:\n            path = os.path.normpath(os.path.join(path, '../'))\n    raise AssertionError('called from outside of the gits')\n\n\n@memoize_by_cwd\ndef get_root():\n    return _get_root_new()\n\n\n@memoize_by_cwd\ndef get_pre_commit_path():\n    return os.path.join(get_root(), '.git/hooks/pre-commit')\n\n\ndef create_pre_commit():\n    path = get_pre_commit_path()\n    pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')\n    local.path(path).write(local.path(pre_commit_file).read())\n    original_mode = os.stat(path).st_mode\n    os.chmod(path, original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n\ndef remove_pre_commit():\n    local.path(get_pre_commit_path()).delete()\n\n\ndef get_head_sha(git_repo_path):\n    with local.cwd(git_repo_path):\n        return local['git']['rev-parse', 'HEAD']().strip()\n\n\n@memoize_by_cwd\ndef get_staged_files():\n    return local['git']['diff', '--staged', '--name-only']().splitlines()\n\n\n@memoize_by_cwd\ndef get_all_files():\n    return local['git']['ls-files']().splitlines()\n\n\ndef get_files_matching(all_file_list_strategy):\n    @functools.wraps(all_file_list_strategy)\n    @memoize_by_cwd\n    def wrapper(expr):\n        regex = re.compile(expr)\n        return set(filter(os.path.exists, (\n            filename\n            for filename in all_file_list_strategy()\n            if regex.search(filename)\n        )))\n    return wrapper\n\n\nget_staged_files_matching = get_files_matching(get_staged_files)\nget_all_files_matching = get_files_matching(get_all_files)\n", "path": "pre_commit/git.py"}]}