Repository: pre-commit/pre-commit
Pull request #789 (2018-07-05 22:44:53)

Added Python 3.7 to Travis CI


Patch:
diff --git a/.travis.yml b/.travis.yml
index 094274b..d79dc4a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,10 @@ matrix:
             python: 3.6
         -   env: TOXENV=pypy
             python: pypy2.7-5.10.0
+        -   env: TOXENV=py37
+            python: 3.7
+            sudo: required
+            dist: xenial
 install: pip install coveralls tox
 script: tox
 before_install:
diff --git a/appveyor.yml b/appveyor.yml
index 958acaf..271edaf 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -27,4 +27,3 @@ test_script: tox
 cache:
   - '%LOCALAPPDATA%\pip\cache'
   - '%USERPROFILE%\.cache\pre-commit'
-  - '%USERPROFILE%\.cargo'
diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py
index f5947de..6b2d16f 100644
--- a/pre_commit/commands/install_uninstall.py
+++ b/pre_commit/commands/install_uninstall.py
@@ -6,7 +6,6 @@ import logging
 import os.path
 import sys
 
-from pre_commit import git
 from pre_commit import output
 from pre_commit.repository import repositories
 from pre_commit.util import cmd_output
@@ -30,11 +29,6 @@ TEMPLATE_START = '# start templated\n'
 TEMPLATE_END = '# end templated\n'
 
 
-def _hook_paths(git_root, hook_type):
-    pth = os.path.join(git.get_git_dir(git_root), 'hooks', hook_type)
-    return pth, '{}.legacy'.format(pth)
-
-
 def is_our_script(filename):
     if not os.path.exists(filename):
         return False
@@ -54,7 +48,8 @@ def install(
         )
         return 1
 
-    hook_path, legacy_path = _hook_paths(runner.git_root, hook_type)
+    hook_path = runner.get_hook_path(hook_type)
+    legacy_path = hook_path + '.legacy'
 
     mkdirp(os.path.dirname(hook_path))
 
@@ -107,8 +102,8 @@ def install_hooks(runner, store):
 
 def uninstall(runner, hook_type='pre-commit'):
     """Uninstall the pre-commit hooks."""
-    hook_path, legacy_path = _hook_paths(runner.git_root, hook_type)
-
+    hook_path = runner.get_hook_path(hook_type)
+    legacy_path = hook_path + '.legacy'
     # If our file doesn't exist or it isn't ours, gtfo.
     if not os.path.exists(hook_path) or not is_our_script(hook_path):
         return 0
diff --git a/pre_commit/runner.py b/pre_commit/runner.py
index 5310700..c172d3f 100644
--- a/pre_commit/runner.py
+++ b/pre_commit/runner.py
@@ -34,3 +34,6 @@ class Runner(object):
     @cached_property
     def config(self):
         return load_config(self.config_file_path)
+
+    def get_hook_path(self, hook_type):
+        return os.path.join(git.get_git_dir(self.git_root), 'hooks', hook_type)
diff --git a/tox.ini b/tox.ini
index 1567493..ddc2319 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
 [tox]
 project = pre_commit
 # These should match the travis env list
-envlist = py27,py35,py36,pypy
+envlist = py27,py35,py36,py37,pypy
 
 [testenv]
 deps = -rrequirements-dev.txt


Test patch:
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index 7345cfb..6aa9c7f 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -640,7 +640,7 @@ def test_commit_msg_integration_passing(
 def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store):
     runner = Runner(commit_msg_repo, C.CONFIG_FILE)
 
-    hook_path = os.path.join(commit_msg_repo, '.git/hooks/commit-msg')
+    hook_path = runner.get_hook_path('commit-msg')
     mkdirp(os.path.dirname(hook_path))
     with io.open(hook_path, 'w') as hook_file:
         hook_file.write(