Skip to content

Commit

Permalink
feat: use prebuilt upstream exe in shfmt, src install in shfmt-src
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 12, 2023
1 parent 65336de commit 286f22a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
31 changes: 30 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
- id: shfmt
name: shfmt
description: Shell source code formatter (native install)
description: Shell source code formatter (prebuilt upstream executable)
language: python
entry: wrun
args:
- --url
- darwin/amd64=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_darwin_amd64#ae1d1ab961c113fb3dc2ff1150f33c3548983550d91da889b3171a5bcfaab14f
- --url
- darwin/arm64=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_darwin_arm64#ad7ff6f666adba3d801eb17365a15539f07296718d39fb62cc2fde6b527178aa
- --url
- linux/386=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_386#9f0b53d765e11c519be1866c5c3e4614f3f4bac4c982c935f879f561c38f17c1
- --url
- linux/amd64=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64#0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3
- --url
- linux/arm=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_arm#3d1f5a1aede8161293bc42007af5b983f16d62857736c789f062346ed839f299
- --url
- linux/arm64=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_arm64#111612560d15bd53d8e8f8f85731176ce12f3b418ec473d39a40ed6bbec772de
- --url
- windows/386=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_windows_386.exe#8bd0422554dd6ce5e07d9d17d020d89254b5c056009005df824e39a8cbdcf6aa
- --url
- windows/amd64=https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_windows_amd64.exe#2807b4af91fbbd961b68716de06c044f1b4f897457fc89fba216e5e2e351c64f
- --
- -w
- -s
types: [shell]
exclude_types: [csh, tcsh, zsh]
stages: [commit, merge-commit, push, manual]

- id: shfmt-src
name: shfmt
description: Shell source code formatter (build from source)
language: golang
# Note: keep Go version in `go.mod` in sync with shfmt's required Go version
additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.7.0]
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ Usage in `.pre-commit-config.yaml`:

```yaml
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-1
rev: v3.7.0-2
hooks:
# Choose one of:
- id: shfmt # native (requires/installs Go to build)
- id: shfmt # prebuilt upstream executable
- id: shfmt-src # build from source (requires/installs Go to build)
- id: shfmt-docker # Docker image (requires Docker to run)
```

> #### Note
> From v3.7.0-2 on, the `shfmt` id points to the variant that uses a prebuilt
> upstream executable. The one that builds from source is available as
> `shfmt-src`.
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[project]
name = "pre-commit-shfmt"
version = "3.7.0-2"
dependencies = [
"wrun-py",
]

0 comments on commit 286f22a

Please sign in to comment.