pre-commit/pre_commit
Michael Bolin 40c83283d6 [rfc] Support Sapling (alternative SCM) when using precommit
When using [Sapling SCM](https://sapling-scm.com/) with a Git
repository, precommit expectedly fails today because it shells
out to `git` to get the list of modified files in the working
copy. In a Sapling clone of a Git repository, these calls will
fail.

While most of the logic in precommit that deals with talking
to Git today is encapsulated in `git.py`, calls to `git` are
sprinkled throughout the project and are called directly. In
order to support alternative SCMs, such as Sapling, ideally
there would be a more generic "SCM" interface that business
logic would call into with both Git and Sapling implementations.

Though this PR does not attempt to introduce such an interface.
Instead, it is just a basic PoC to provide evidence that
something like this could be made to work. For the moment, it
takes a shortcut and simply sprinkles "if Sapling" checks
in `git.py` in enough places that I could get precommit to
run in a Sapling working copy in the simple case where I had
only one file modified locally.

My higher-level question is whether the precommit project
would be open to accepting changes to support Sapling,
either via the introduction of an SCM-agnostic interface or
some other means.
2024-03-01 15:52:20 -08:00
..
commands [rfc] Support Sapling (alternative SCM) when using precommit 2024-03-01 15:52:20 -08:00
languages fix building golang hooks during commit --all 2024-02-18 13:03:44 -05:00
meta_hooks python3.9+ 2023-10-28 14:20:37 -04:00
resources Upgrade to ruby-build v20230330 2023-04-18 10:58:57 -07:00
__init__.py Initial commit. 2014-03-12 20:25:19 -07:00
__main__.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
all_languages.py Add haskell language support to pre-commit. 2023-07-22 16:28:48 -04:00
clientlib.py attempt minimum_pre_commit_version first when parsing configs 2023-12-09 15:34:16 -05:00
color.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
constants.py make --hook-type and stages match 2023-03-11 14:26:14 -05:00
envcontext.py python3.9+ 2023-10-28 14:20:37 -04:00
error_handler.py python3.9+ 2023-10-28 14:20:37 -04:00
errors.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
file_lock.py python3.9+ 2023-10-28 14:20:37 -04:00
git.py [rfc] Support Sapling (alternative SCM) when using precommit 2024-03-01 15:52:20 -08:00
hook.py python3.9+ 2023-10-28 14:20:37 -04:00
lang_base.py python3.9+ 2023-10-28 14:20:37 -04:00
logging_handler.py python3.9+ 2023-10-28 14:20:37 -04:00
main.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-01-12 16:32:44 +00:00
output.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
parse_shebang.py python3.9+ 2023-10-28 14:20:37 -04:00
prefix.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
repository.py attempt minimum_pre_commit_version first when parsing configs 2023-12-09 15:34:16 -05:00
staged_files_only.py [rfc] Support Sapling (alternative SCM) when using precommit 2024-03-01 15:52:20 -08:00
store.py python3.9+ 2023-10-28 14:20:37 -04:00
util.py Address deprecation warning in shutil.rmtree(onerror=...) 2023-12-09 14:51:01 -05:00
xargs.py python3.9+ 2023-10-28 14:20:37 -04:00
yaml.py add pre_commit.yaml module 2023-01-02 18:42:34 -05:00