diff --git a/pre_commit_mirror_maker/all/hooks.yaml b/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml similarity index 100% rename from pre_commit_mirror_maker/all/hooks.yaml rename to pre_commit_mirror_maker/all/.pre-commit-hooks.yaml diff --git a/pre_commit_mirror_maker/make_repo.py b/pre_commit_mirror_maker/make_repo.py index c1d1f64..77e711a 100644 --- a/pre_commit_mirror_maker/make_repo.py +++ b/pre_commit_mirror_maker/make_repo.py @@ -2,8 +2,8 @@ import contextlib import io -import os import os.path +import shutil import subprocess import pkg_resources @@ -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(( diff --git a/pre_commit_mirror_maker/node/hooks.yaml b/pre_commit_mirror_maker/node/.pre-commit-hooks.yaml similarity index 100% rename from pre_commit_mirror_maker/node/hooks.yaml rename to pre_commit_mirror_maker/node/.pre-commit-hooks.yaml diff --git a/setup.py b/setup.py index f8312d4..529964c 100644 --- a/setup.py +++ b/setup.py @@ -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/*', diff --git a/tests/make_repo_test.py b/tests/make_repo_test.py index fda5c75..59ec7ae 100644 --- a/tests/make_repo_test.py +++ b/tests/make_repo_test.py @@ -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 @@ -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', @@ -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 @@ -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') @@ -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') @@ -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')