Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add creation of .pre-commit-hooks.yaml #19

Merged
merged 1 commit into from
Jan 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pre_commit_mirror_maker/make_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import contextlib
import io
import os
import os.path
import shutil
import subprocess

import pkg_resources
Expand Down Expand Up @@ -84,6 +84,10 @@ def _apply_version_and_commit(
)
format_files_to_directory(src_dir, '.', format_vars)

# https://github.com/pre-commit/pre-commit/pull/470 moved the default
# file to .pre-commit-hooks.yaml -- populate the legacy file as well
shutil.copy('.pre-commit-hooks.yaml', 'hooks.yaml')

# Commit and tag
subprocess.check_call(('git', 'add', '.'))
subprocess.check_call((
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
},
package_data={
'pre_commit_mirror_maker': [
'all/.pre-commit-hooks.yaml',
'all/.version',
'all/*',
'node/.npmignore',
'node/.pre-commit-hooks.yaml',
'node/*',
'python/*',
'ruby/*',
Expand Down
7 changes: 6 additions & 1 deletion tests/make_repo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_apply_version_and_commit():
)

# Assert that our things got copied over
assert os.path.exists('.pre-commit-hooks.yaml')
assert os.path.exists('hooks.yaml')
assert os.path.exists('__fake_gem.gemspec')
# Assert that we set the version file correctly
Expand All @@ -115,7 +116,7 @@ def test_arguments():
_apply_version_and_commit(
'0.6.2', 'python', 'yapf', r'\.py$', 'yapf', ('-i',),
)
assert yaml.safe_load(io.open('hooks.yaml').read()) == [{
assert yaml.safe_load(io.open('.pre-commit-hooks.yaml').read()) == [{
'id': 'yapf',
'name': 'yapf',
'entry': 'yapf',
Expand All @@ -137,6 +138,7 @@ def test_make_repo_starting_empty():
)

# Assert that our things got copied over
assert os.path.exists('.pre-commit-hooks.yaml')
assert os.path.exists('hooks.yaml')
assert os.path.exists('__fake_gem.gemspec')
# Assert that we set the version fiel correctly
Expand Down Expand Up @@ -186,6 +188,7 @@ def test_ruby_integration():
make_repo('.', 'ruby', 'scss-lint', r'\.scss$', 'scss-lint', ())
# Our files should exist
assert os.path.exists('.version')
assert os.path.exists('.pre-commit-hooks.yaml')
assert os.path.exists('hooks.yaml')
assert os.path.exists('__fake_gem.gemspec')

Expand All @@ -203,6 +206,7 @@ def test_node_integration():
make_repo('.', 'node', 'jshint', r'\.js$', 'jshint', ())
# Our files should exist
assert os.path.exists('.version')
assert os.path.exists('.pre-commit-hooks.yaml')
assert os.path.exists('hooks.yaml')
assert os.path.exists('package.json')

Expand All @@ -220,6 +224,7 @@ def test_python_integration():
make_repo('.', 'python', 'flake8', r'\.py$', 'flake8', ())
# Our files should exist
assert os.path.exists('.version')
assert os.path.exists('.pre-commit-hooks.yaml')
assert os.path.exists('hooks.yaml')
assert os.path.exists('setup.py')

Expand Down