pre-commit/pre_commit/commands
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
..
__init__.py Move commands into their own files. 2014-06-13 19:52:14 -07:00
autoupdate.py python3.9+ 2023-10-28 14:20:37 -04:00
clean.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
gc.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
hook_impl.py python3.9+ 2023-10-28 14:20:37 -04:00
init_templatedir.py implement default_install_hook_types 2022-04-02 15:11:31 -04:00
install_uninstall.py shlex.join is always available in 3.8+ 2023-07-01 17:22:42 -04:00
migrate_config.py deprecate python_venv language 2023-02-04 14:26:09 -05:00
run.py [rfc] Support Sapling (alternative SCM) when using precommit 2024-03-01 15:52:20 -08:00
sample_config.py remove obsolete comment 2022-11-27 16:30:58 -05:00
try_repo.py add pre_commit.yaml module 2023-01-02 18:42:34 -05:00
validate_config.py python3.9+ 2023-10-28 14:20:37 -04:00
validate_manifest.py python3.9+ 2023-10-28 14:20:37 -04:00