Repository: pre-commit/pre-commit-mirror-maker

Issue:
How to setup release to include config attributes
It seems that the script overwrites the yaml confile by default (instead of updating it). If I need to maintain a config param such as `pass_filenames: false`. How would I go about doing that?

The repo in question: https://github.com/adithyabsk/mirrors-brakeman

Discussion:
adithyabsk: @asottile let me know if you have any other comments

Patch:
diff --git a/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml b/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml
index 73d2e79..a582766 100644
--- a/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml
+++ b/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml
@@ -5,4 +5,5 @@
     '{match_key}': {match_val}
     args: {args}
     require_serial: {require_serial}
+    pass_filenames: {pass_filenames}
     additional_dependencies: {additional_dependencies}
diff --git a/pre_commit_mirror_maker/main.py b/pre_commit_mirror_maker/main.py
index 8accead..f44fc0d 100644
--- a/pre_commit_mirror_maker/main.py
+++ b/pre_commit_mirror_maker/main.py
@@ -65,6 +65,11 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
         '--require-serial', action='store_true',
         help='Set `require_serial: true` for the hook',
     )
+    parser.add_argument(
+        '--pass-filenames', action='store_true',
+        help='Set `pass_filenames: true` for the hook',
+    )
+
     args = parser.parse_args(argv)
 
     make_repo(
@@ -76,6 +81,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
         match_val=f'[{args.types}]' if args.types else args.files_regex,
         args=json.dumps(split_by_commas(args.args)),
         require_serial=json.dumps(args.require_serial),
+        pass_filenames=json.dumps(args.pass_filenames),
     )
     return 0
 


Test patch:
diff --git a/tests/main_test.py b/tests/main_test.py
index 8f818cf..a577057 100644
--- a/tests/main_test.py
+++ b/tests/main_test.py
@@ -39,7 +39,7 @@ def test_main_passes_args(mock_make_repo):
         '.',
         language='ruby', name='scss-lint', entry='scss-lint-entry',
         match_key='files', match_val=r'\.scss$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
 
 
diff --git a/tests/make_repo_test.py b/tests/make_repo_test.py
index 773ba9b..0543ef6 100644
--- a/tests/make_repo_test.py
+++ b/tests/make_repo_test.py
@@ -66,6 +66,7 @@ def test_commit_version(in_git_dir):
         version='0.24.1', language='ruby', name='scss-lint', entry='scss-lint',
         match_key='files', match_val=r'\.scss$', args='[]',
         additional_dependencies='[]', require_serial='false',
+        pass_filenames='false',
     )
 
     # Assert that our things got copied over
@@ -86,6 +87,7 @@ def test_arguments(in_git_dir):
         version='0.6.2', language='python', name='yapf', entry='yapf',
         match_key='files', match_val=r'\.py$', args='["-i"]',
         additional_dependencies='["scikit-learn"]', require_serial='false',
+        pass_filenames='false',
     )
     contents = in_git_dir.join('.pre-commit-hooks.yaml').read()
     assert yaml.safe_load(contents) == [{
@@ -96,6 +98,7 @@ def test_arguments(in_git_dir):
         'files': r'\.py$',
         'args': ['-i'],
         'require_serial': False,
+        'pass_filenames': False,
         'additional_dependencies': ['scikit-learn'],
     }]
 
@@ -112,7 +115,7 @@ def test_make_repo_starting_empty(in_git_dir, fake_versions):
         '.',
         language='ruby', name='scss-lint', entry='scss-lint',
         match_key='files', match_val=r'\.scss$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
 
     # Assert that our things got copied over
@@ -144,7 +147,7 @@ def test_make_repo_starting_at_version(in_git_dir, fake_versions):
         '.',
         language='ruby', name='scss-lint', entry='scss-lint',
         match_key='files', match_val=r'\.scss$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
 
     assert not in_git_dir.join('hooks.yaml').exists()
@@ -164,7 +167,7 @@ def test_ruby_integration(in_git_dir):
         '.',
         language='ruby', name='scss-lint', entry='scss-lint',
         match_key='files', match_val=r'\.scss$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
     # Our files should exist
     assert in_git_dir.join('.version').exists()
@@ -184,7 +187,7 @@ def test_node_integration(in_git_dir):
         '.',
         language='node', name='jshint', entry='jshint',
         match_key='files', match_val=r'\.js$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
     # Our files should exist
     assert in_git_dir.join('.version').exists()
@@ -204,7 +207,7 @@ def test_python_integration(in_git_dir):
         '.',
         language='python', name='flake8', entry='flake8',
         match_key='files', match_val=r'\.py$', args='[]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
     # Our files should exist
     assert in_git_dir.join('.version').exists()
@@ -227,7 +230,7 @@ def test_rust_integration(in_git_dir):
         '.',
         language='rust', name='shellharden', entry='shellharden',
         match_key='types', match_val='shell', args='["--replace"]',
-        require_serial='false',
+        require_serial='false', pass_filenames='false',
     )
     # Our files should exist
     assert in_git_dir.join('.version').exists()