mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #313 from pre-commit/travis_latest_git
Add python3.5, pypy3, and latest git to travis
This commit is contained in:
commit
97735a3883
7 changed files with 48 additions and 5 deletions
16
.travis.yml
16
.travis.yml
|
|
@ -4,7 +4,10 @@ env: # These should match the tox env list
|
|||
- TOXENV=py27
|
||||
- TOXENV=py33
|
||||
- TOXENV=py34
|
||||
- TOXENV=py35
|
||||
- TOXENV=pypy
|
||||
- TOXENV=pypy3
|
||||
- TOXENV=py27 LATEST_GIT=1
|
||||
install: pip install coveralls tox
|
||||
script: tox
|
||||
# Special snowflake. Our tests depend on making real commits.
|
||||
|
|
@ -13,6 +16,13 @@ before_install:
|
|||
- git config --global user.email "user@example.com"
|
||||
# Our tests inspect some of *our* git history
|
||||
- git fetch --unshallow
|
||||
- git --version
|
||||
- |
|
||||
if [ "$LATEST_GIT" = "1" ]; then
|
||||
./latest-git.sh
|
||||
export PATH="/tmp/git:$PATH"
|
||||
fi
|
||||
- git --version
|
||||
after_success:
|
||||
- coveralls
|
||||
sudo: false
|
||||
|
|
@ -20,3 +30,9 @@ cache:
|
|||
directories:
|
||||
- $HOME/.cache/pip
|
||||
- $HOME/.pre-commit
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- deadsnakes
|
||||
packages:
|
||||
- python3.5-dev
|
||||
|
|
|
|||
7
latest-git.sh
Executable file
7
latest-git.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# This is a script used in travis-ci to have latest git
|
||||
set -ex
|
||||
git clone git://github.com/git/git --depth 1 /tmp/git
|
||||
pushd /tmp/git
|
||||
make -j 8
|
||||
popd
|
||||
|
|
@ -9,6 +9,7 @@ import stat
|
|||
import sys
|
||||
|
||||
from pre_commit.logging_handler import LoggingHandler
|
||||
from pre_commit.util import mkdirp
|
||||
from pre_commit.util import resource_filename
|
||||
|
||||
|
||||
|
|
@ -54,8 +55,7 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
|
|||
hook_path = runner.get_hook_path(hook_type)
|
||||
legacy_path = hook_path + '.legacy'
|
||||
|
||||
if not os.path.exists(os.path.dirname(hook_path)):
|
||||
os.makedirs(os.path.dirname(hook_path))
|
||||
mkdirp(os.path.dirname(hook_path))
|
||||
|
||||
# If we have an existing hook, move it to pre-commit.legacy
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -26,6 +26,14 @@ def cwd(path):
|
|||
os.chdir(original_cwd)
|
||||
|
||||
|
||||
def mkdirp(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError:
|
||||
if not os.path.exists(path):
|
||||
raise
|
||||
|
||||
|
||||
def memoize_by_cwd(func):
|
||||
"""Memoize a function call based on os.getcwd()."""
|
||||
@functools.wraps(func)
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -23,6 +23,7 @@ setup(
|
|||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from pre_commit.commands.install_uninstall import uninstall
|
|||
from pre_commit.runner import Runner
|
||||
from pre_commit.util import cmd_output
|
||||
from pre_commit.util import cwd
|
||||
from pre_commit.util import mkdirp
|
||||
from pre_commit.util import resource_filename
|
||||
from testing.fixtures import git_dir
|
||||
from testing.fixtures import make_consuming_repo
|
||||
|
|
@ -83,7 +84,9 @@ def test_install_pre_commit(tempdir_factory):
|
|||
def test_install_hooks_directory_not_present(tempdir_factory):
|
||||
path = git_dir(tempdir_factory)
|
||||
# Simulate some git clients which don't make .git/hooks #234
|
||||
shutil.rmtree(os.path.join(path, '.git', 'hooks'))
|
||||
hooks = os.path.join(path, '.git', 'hooks')
|
||||
if os.path.exists(hooks): # pragma: no cover (latest git)
|
||||
shutil.rmtree(hooks)
|
||||
runner = Runner(path)
|
||||
install(runner)
|
||||
assert os.path.exists(runner.pre_commit_path)
|
||||
|
|
@ -94,8 +97,9 @@ def test_install_hooks_dead_symlink(
|
|||
tempdir_factory,
|
||||
): # pragma: no cover (non-windows)
|
||||
path = git_dir(tempdir_factory)
|
||||
os.symlink('/fake/baz', os.path.join(path, '.git', 'hooks', 'pre-commit'))
|
||||
runner = Runner(path)
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
os.symlink('/fake/baz', os.path.join(path, '.git', 'hooks', 'pre-commit'))
|
||||
install(runner)
|
||||
assert os.path.exists(runner.pre_commit_path)
|
||||
|
||||
|
|
@ -249,6 +253,7 @@ def test_install_existing_hooks_no_overwrite(tempdir_factory):
|
|||
runner = Runner(path)
|
||||
|
||||
# Write out an "old" hook
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as hook_file:
|
||||
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -274,6 +279,7 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory):
|
|||
runner = Runner(path)
|
||||
|
||||
# Write out an "old" hook
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as hook_file:
|
||||
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -302,6 +308,7 @@ def test_failing_existing_hook_returns_1(tempdir_factory):
|
|||
runner = Runner(path)
|
||||
|
||||
# Write out a failing "old" hook
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as hook_file:
|
||||
hook_file.write('#!/usr/bin/env bash\necho "fail!"\nexit 1\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -330,6 +337,7 @@ def test_install_overwrite(tempdir_factory):
|
|||
runner = Runner(path)
|
||||
|
||||
# Write out the "old" hook
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as hook_file:
|
||||
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -347,6 +355,7 @@ def test_uninstall_restores_legacy_hooks(tempdir_factory):
|
|||
runner = Runner(path)
|
||||
|
||||
# Write out an "old" hook
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as hook_file:
|
||||
hook_file.write('#!/usr/bin/env bash\necho "legacy hook"\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -374,6 +383,7 @@ def test_replace_old_commit_script(tempdir_factory):
|
|||
IDENTIFYING_HASH, PREVIOUS_IDENTIFYING_HASHES[-1],
|
||||
)
|
||||
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as pre_commit_file:
|
||||
pre_commit_file.write(new_contents)
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
@ -390,6 +400,7 @@ def test_uninstall_doesnt_remove_not_our_hooks(tempdir_factory):
|
|||
path = git_dir(tempdir_factory)
|
||||
with cwd(path):
|
||||
runner = Runner(path)
|
||||
mkdirp(os.path.dirname(runner.pre_commit_path))
|
||||
with io.open(runner.pre_commit_path, 'w') as pre_commit_file:
|
||||
pre_commit_file.write('#!/usr/bin/env bash\necho 1\n')
|
||||
make_executable(runner.pre_commit_path)
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -1,7 +1,7 @@
|
|||
[tox]
|
||||
project = pre_commit
|
||||
# These should match the travis env list
|
||||
envlist = py26,py27,py33,py34,pypy
|
||||
envlist = py26,py27,py33,py34,py35,pypy,pypy3
|
||||
|
||||
[testenv]
|
||||
deps = -rrequirements-dev.txt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue