| from __future__ import annotations |
| from typing import Sequence |
| from pre_commit_hooks.util import cmd_output |
| def main(argv: Sequence[str] | None = None) -> int: |
| parser = argparse.ArgumentParser() |
| parser.add_argument('filenames', nargs='*') |
| args = parser.parse_args(argv) |
| 'PRE_COMMIT_FROM_REF' in os.environ and |
| 'PRE_COMMIT_TO_REF' in os.environ |
| os.environ['PRE_COMMIT_FROM_REF'], |
| os.environ['PRE_COMMIT_TO_REF'], |
| 'git', 'diff', '--diff-filter=A', '--raw', diff_arg, '--', |
| for line in added_diff.splitlines(): |
| metadata, filename = line.split('\t', 1) |
| new_mode = metadata.split(' ')[1] |
| print(f'{filename}: new submodule introduced') |
| print('This commit introduces new submodules.') |
| print('Did you unintentionally `git add .`?') |
| print('To fix: git rm {thesubmodule} # no trailing slash') |
| print('Also check .gitmodules') |
| if __name__ == '__main__': |