mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-21 22:03:45 -07:00
Add support as pre-commit hook
Changes: * .pre-commit-hooks.yaml: defines this shellcheck repo as a hook for pre-commit * .travis.yml: make sure .pre-commit-hooks.yams is in sync with release
This commit is contained in:
parent
28d3279ba6
commit
5517305827
3 changed files with 25 additions and 0 deletions
7
.pre-commit-hooks.yaml
Normal file
7
.pre-commit-hooks.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# See https://pre-commit.com for more information
|
||||||
|
- id: shellcheck
|
||||||
|
name: shellcheck shell scripts
|
||||||
|
description: Validate shell scripts with shellcheck running in Docker
|
||||||
|
language: docker_image
|
||||||
|
entry: koalaman/shellcheck:v0.7.1
|
||||||
|
types: [shell]
|
11
.travis.yml
11
.travis.yml
|
@ -65,6 +65,17 @@ before_install: |
|
||||||
test "$TRAVIS_BRANCH" = master && TAGS="$TAGS latest" || true
|
test "$TRAVIS_BRANCH" = master && TAGS="$TAGS latest" || true
|
||||||
test -n "$TRAVIS_TAG" && TAGS="$TAGS stable $TRAVIS_TAG" || true
|
test -n "$TRAVIS_TAG" && TAGS="$TAGS stable $TRAVIS_TAG" || true
|
||||||
echo "Tags are $TAGS"
|
echo "Tags are $TAGS"
|
||||||
|
set -e
|
||||||
|
# The version encoded in pre-commit and built version must be in sync. If not,
|
||||||
|
# the pre-commit version was forgotten to be updated.
|
||||||
|
if [ -n "$TRAVIS_TAG" ]; then
|
||||||
|
precommit_tag="$(awk -F: '/^ *entry:/ {print $NF}' .pre-commit-hooks.yaml)"
|
||||||
|
if [ "$TRAVIS_TAG" != "$precommit_tag" ]; then
|
||||||
|
echo "Wrong version number $precommit_tag in .pre-commit-hooks.yaml"
|
||||||
|
sleep 1 # give Travis time to grab the error message
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# This is in global context and runs for every stage that doesn't override it.
|
# This is in global context and runs for every stage that doesn't override it.
|
||||||
script:
|
script:
|
||||||
|
|
|
@ -211,6 +211,13 @@ docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:stable myscript
|
||||||
|
|
||||||
or use `koalaman/shellcheck-alpine` if you want a larger Alpine Linux based image to extend. It works exactly like a regular Alpine image, but has shellcheck preinstalled.
|
or use `koalaman/shellcheck-alpine` if you want a larger Alpine Linux based image to extend. It works exactly like a regular Alpine image, but has shellcheck preinstalled.
|
||||||
|
|
||||||
|
From [pre-commit](https://pre-commit.com/), add this to your `.pre-commit-config.yaml`:
|
||||||
|
|
||||||
|
- repo: https://github.com/koalaman/shellcheck
|
||||||
|
rev: '' # Use the sha / tag you want to point at
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
||||||
|
|
||||||
Using the [nix package manager](https://nixos.org/nix):
|
Using the [nix package manager](https://nixos.org/nix):
|
||||||
```sh
|
```sh
|
||||||
nix-env -iA nixpkgs.shellcheck
|
nix-env -iA nixpkgs.shellcheck
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue