Commit graph

323 commits

Author SHA1 Message Date
Matan Shavit
ae5018d3e5
Add Bun language support
Implements Bun as a new language option for pre-commit hooks, enabling
hooks to run using the Bun JavaScript runtime and package manager.

- Add bun.py language implementation with binary download/install
- Support system-installed Bun or automatic version download
- Add comprehensive tests including version handling and hook execution
- Register bun in all_languages.py
- Include test repository fixture for integration tests
2025-10-28 21:15:51 -04:00
anthony sottile
f415f6c4d7 py310+
Committed via https://github.com/asottile/all-repos
2025-10-09 17:44:05 -04:00
anthony sottile
2930ea0fcd handle SecurityOptions: null in docker response 2025-09-06 14:40:20 -04:00
Eric Hanson
6f1f433a9c Julia language: skip startup.jl file 2025-08-02 14:35:27 -04:00
Matthew Hughes
466f6c4a39 Fix permission errors for mounts in rootless docker
By running containers in a rootless docker context as root. This is
because user and group IDs are remapped in the user namespaces uses by
rootless docker, and it's unlikely that the current user ID will map to
the same ID under this remap (see docs[1] for some more details).
Specifically, it means ownership of mounted volumes will not be for the
current user and trying to write can result in permission errors.

This change borrows heavily from an existing PR[2].

The output format of `docker system info` I don't think is
documented/guaranteed anywhere, but it should corresponding to the
format of a `/info` API request to Docker[3]

The added test _hopes_ to avoid regressions in this behaviour, but since
tests aren't run in a rootless docker context on the PR checks (and I
couldn't find an easy way to make it the case) there's still a risk of
regressions sneaking in.

Link: https://docs.docker.com/engine/security/rootless/ [1]
Link: https://github.com/pre-commit/pre-commit/pull/1484/ [2]
Link: https://docs.docker.com/reference/api/engine/version/v1.48/#tag/System/operation/SystemAuth [3]
Co-authored-by: Kurt von Laven <Kurt-von-Laven@users.noreply.github.com>
Co-authored-by: Fabrice Flore-Thébault <ffloreth@redhat.com>
2025-05-23 17:01:10 -04:00
Anthony Sottile
3e8d0f5e1c adjust python default_language_version to prefer versioned exe 2025-03-18 14:55:24 -04:00
Lorenz Walthert
c2c061cf63 fix: ensure env patch is applied for vanilla emulation
otherwise, installing the hooks when RENV_USER env variable is set (e.g. in RStudio with renv project) will result in executing the installation script in the wrong renv
2025-01-20 13:13:36 -05:00
Anthony Sottile
cb14bc2d9c
Merge pull request #3304 from AleksaC/go-toolchain
disable automatic toolchain switching for golang hooks
2024-11-25 18:54:37 -05:00
AleksaC
109628c505 disable automatic toolchain switching for golang hooks 2024-11-25 18:47:18 -05:00
Fredrik Ekre
85783bdc0b Add support for julia hooks
This patch adds 2nd class support for hooks using julia as the language.
pre-commit will install any dependencies defined in the hooks repo
`Project.toml` file, with support for `additional_dependencies` as well.
Julia doesn't (yet) have a way to install binaries/scripts so for julia
hooks the `entry` value is a (relative) path to a julia script within
the hooks repository. When executing a julia hook the (globally
installed) julia interpreter is prepended to the entry.

Example `.pre-commit-hooks.yaml`:

```yaml
- id: foo
  name: ...
  language: julia
  entry: bin/foo.jl --arg1
```

Example hooks repo: https://github.com/fredrikekre/runic-pre-commit/tree/fe/julia
Accompanying pre-commit.com PR: https://github.com/pre-commit/pre-commit.com/pull/998

Fixes #2689.
2024-11-25 18:31:25 -05:00
pre-commit-ci[bot]
917e2102be [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-07-29 21:59:19 +00:00
Lorenz Walthert
da0c1d0cfa implement health check for language:r 2024-07-28 15:44:07 -04:00
Anthony Sottile
296f59266e determine rust default language version independent of rust-toolchain.toml 2024-05-10 17:06:29 -04:00
Gaëtan Lehmann
e58009684c give docker a tty output when expecting color
this makes the behavior more consistent with the system language
and would help the executable run in a docker container to
produce a colored output.
2024-03-02 11:51:34 -05:00
Anthony Sottile
61d9c95cc1 fix building golang hooks during commit --all 2024-02-18 13:03:44 -05:00
Anthony Sottile
08478ec176 python 3.9+: use removeprefix 2023-12-09 16:04:25 -05:00
Anthony Sottile
75f2710bd4 3.13 removed the simpler importlib.resources api 2023-10-28 14:39:49 -04:00
Anthony Sottile
7f15dc75ee python3.9+ 2023-10-28 14:20:37 -04:00
Roel Adriaans
493c20ce91 Use the --include command, hides warning messages
Fixes #1983
2023-09-08 15:12:54 +02:00
Alex Brandt
60273ca81e Add haskell language support to pre-commit. 2023-07-22 16:28:48 -04:00
pre-commit-ci[bot]
50b1511a5b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-06-13 22:04:03 +00:00
Jay Soffian
9a7ed8be09 Force gem installation into envdir
RubyGems allows OS packagers to specify defaults for `--install-dir`
and `--bindir` and these take precedence over `GEM_HOME`. The only way
to override the defaults is to explicitly specify the options ourselves
when running `gem install`.

Examples of OSes where this is the case are RedHat 9.2 and Gentoo.

Fixes #2799.
2023-06-13 18:03:52 -04:00
Lorenz Walthert
cd09c3525e avoid quoting and escaping while installing R hooks by writing code to tempfile instead of execute R code inline 2023-05-17 18:00:00 -04:00
Anthony Sottile
8923fa368a r does not support language_version currently 2023-05-13 15:46:34 -04:00
Eric DeLabar
84f040f58a
fix #2235 2023-04-03 15:50:55 -04:00
Anthony Sottile
ee71a9345c set CARGO_HOME while executing rustup 2023-03-25 13:06:22 -04:00
Anthony Sottile
a412e5492d don't set CARGO_HOME in rust
this adds a 270 MB registry cache in the output
2023-03-17 12:55:34 -04:00
marsha
5ce4a549d3 prefer sys.platform over os.name when checking for windows OS 2023-03-03 22:13:07 -06:00
Anthony Sottile
2700a7d622 set RUSTUP_HOME when using a non-system rust 2023-02-27 20:49:22 -05:00
Anthony Sottile
8d84a7a270 resources_bytesio is only used by ruby 2023-02-20 21:47:01 -05:00
Anthony Sottile
d3883ce7f7 move languages.all and languages.helpers out of languages 2023-02-20 18:03:45 -05:00
marsha
8db5aaf4f3 future-proof dotnet build command
see https://github.com/dotnet/sdk/issues/30624#issuecomment-1435457318
2023-02-17 21:34:24 -06:00
marsha
915b930a5d test dotnet directly 2023-02-07 21:47:26 -06:00
Anthony Sottile
0afb95ccca test docker and docker_image directly 2023-02-04 17:22:06 -05:00
Anthony Sottile
7260d24d0f Revert "also ignore Gemfile in project"
This reverts commit f4bd44996c.
2023-02-01 18:17:24 -05:00
Anthony Sottile
420902f67c fix r local hooks
`language: r` acts more like `language: script` so we have to *not* append
the prefix when run with `repo: local`
2023-01-29 17:27:42 -05:00
Anthony Sottile
f4bd44996c also ignore Gemfile in project
this starts failing with ruby 3.2.0
2023-01-28 16:44:44 -05:00
Anthony Sottile
83e05e607e ensure coursier hooks are available offline after install 2023-01-25 14:03:39 -05:00
Anthony Sottile
966c67a832 speed up R unit tests 2023-01-17 14:16:13 -05:00
Anthony Sottile
70bfd76ced coursier: additional_dependencies support 2023-01-17 09:59:04 -05:00
Anthony Sottile
628c876b2d adjust the run_hook api to no longer take Hook 2023-01-16 16:34:01 -05:00
Anthony Sottile
ae34a962d7 make in_env part of the language api 2023-01-16 15:36:29 -05:00
taoufik07
9afd63948e Make Go a first class language 2023-01-13 12:42:57 -05:00
Anthony Sottile
0dbc154380
Merge pull request #2672 from taoufik07/remove_gopath_special_build
Remove `GOPATH` special build
2023-01-02 19:32:08 -05:00
taoufik07
60a42e9419 Remove GOPATH special build 2023-01-02 18:53:14 -05:00
Anthony Sottile
8529a0c1d3 add pre_commit.yaml module 2023-01-02 18:42:34 -05:00
Anthony Sottile
05c8911363 simplify environment_dir 2023-01-01 21:11:56 -05:00
Anthony Sottile
d05b7888ab move clean_path_on_failure out of each hook install 2023-01-01 20:04:58 -05:00
Anthony Sottile
0224be8194
Merge pull request #2667 from pre-commit/env-dir-always-non-null
remove None overload for environment_dir
2023-01-01 19:52:48 -05:00
Anthony Sottile
f0baffb01f remove None overload for environment_dir 2023-01-01 19:20:40 -05:00