[clang] [clang-format] Add pre-commit CI env var support to git-clang-format (PR #188816)
Aditya Goyal via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 16:46:37 PDT 2026
================
@@ -223,6 +228,16 @@ def main():
)
opts = p.parse_args(argv)
+ # When no commits are given explicitly and the pre-commit CI framework's
+ # environment variables are set, use them to define the diff range.
+ if not opts.args and not dash_dash:
+ from_ref = os.environ.get('PRE_COMMIT_FROM_REF')
----------------
goyaladitya05 wrote:
Yeah, these are official pre-commit env variables. Pre-commit sets them automatically with `--from-ref/--to-ref`.
Official Docs: https://github.com/pre-commit/pre-commit/blob/main/pre_commit/commands/run.py#L391-L392
https://github.com/llvm/llvm-project/pull/188816
More information about the cfe-commits
mailing list