Skip to content

Commit

Permalink
Merge pull request #19 from pre-commit/pre_commit_hooks_yaml
Browse files Browse the repository at this point in the history
Add creation of .pre-commit-hooks.yaml
  • Loading branch information
asottile authored Jan 22, 2017
2 parents 3328956 + 7151973 commit 35710d6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
File renamed without changes.
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
File renamed without changes.
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

0 comments on commit 35710d6

Please sign in to comment.