pre-commit/pre_commit
Yuri D'Elia 037bc078dc Improve path canonicalization
The git toplevel is a path with all symlinks leading to the repository
root resolved. When transforming the supplied files to paths relative to
the repository's root we _also_ need to resolve all symlinks up to the
repository's root in order to correctly handle different symlinked paths
that eventually lead to the same repository.

Such paths are currently accepted by git, but are not matched correctly
in pre-commit, as they incorrectly show as out-of-tree.

To relativize paths correctly we iteratively try to replace the trailing
components of the absolute path until the repository root is matched.
The root prefix is then substituted for the real path, yelding a path
with the subtree path untouched. This allows to correctly supply a
symlink within the working tree to git itself.

For paths which are not directly given as an argument to git, using
os.path.realpath() instead is sufficient.

This allows pre-commit to see the subtree path in the same way as
currently accepted by git.
2021-10-28 11:39:24 +02:00
..
commands Add fail_fast support per-hook 2021-10-22 19:16:30 -04:00
languages replace exit(main()) with raise SystemExit(main()) 2021-10-23 13:23:48 -04:00
meta_hooks replace exit(main()) with raise SystemExit(main()) 2021-10-23 13:23:48 -04:00
resources port hook template to bash 2021-09-27 19:34:04 -04:00
__init__.py Initial commit. 2014-03-12 20:25:19 -07:00
__main__.py replace exit(main()) with raise SystemExit(main()) 2021-10-23 13:23:48 -04:00
clientlib.py Add fail_fast support per-hook 2021-10-22 19:16:30 -04:00
color.py warn on old list-style configuration 2020-07-25 13:04:54 -07:00
constants.py Add: post-rewrite hook support 2021-09-01 14:50:59 -05:00
envcontext.py use slightly simpler enum syntax 2020-11-09 12:29:57 -08:00
error_handler.py Distinct error handling exit codes 2020-10-28 11:13:04 -07:00
errors.py check cygwin mismatch earlier 2020-09-20 10:42:11 -07:00
file_lock.py use comparison with sys.platform so mypy understands it 2021-01-25 12:47:07 -08:00
git.py fix pre-commit autoupdate for core.useBuiltinFSMonitor=true on windows 2021-09-13 20:01:25 -04:00
hook.py Add fail_fast support per-hook 2021-10-22 19:16:30 -04:00
logging_handler.py Some manual .format() -> f-strings 2020-01-12 13:39:53 -08:00
main.py Improve path canonicalization 2021-10-28 11:39:24 +02:00
output.py More miscellaneous cleanup 2020-01-13 11:47:34 -08:00
parse_shebang.py Use covdefaults to handle coveragerc 2020-02-29 14:25:19 -08:00
prefix.py Add types to pre-commit 2020-01-12 10:15:01 -08:00
repository.py produce a more useful error message when non-installable things use language_version or additional_dependencies 2021-01-22 13:56:06 -08:00
staged_files_only.py make sure to not discard changes even if submodule.recurse=1 2021-10-01 18:45:36 -04:00
store.py add support for dart as a hook language 2021-08-29 08:57:56 -07:00
util.py add support for dart as a hook language 2021-08-29 08:57:56 -07:00
xargs.py give xargs batch file execution additional headroom 2021-04-04 10:00:55 -07:00