Skip to content

Commit c9f9137

Browse files
damcav35damien cavagnini
andauthored
feat: add some precommit (#274)
- ensure correct formatting with shfmt - ensure correct syntax with shellcheck Co-authored-by: damien cavagnini <damien.cavagnini@corp.ovh.com>
1 parent 51bc582 commit c9f9137

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@ repos:
88
language: script
99
pass_filenames: true
1010
files: "^bin/hardening/"
11+
- id: shfmt
12+
name: shfmt.sh
13+
description: Ensure correct formatting
14+
entry: hooks/shfmt.sh
15+
language: script
16+
pass_filenames: true
17+
files: "^(bin|tests)/hardening/"
18+
- id: shellcheck
19+
name: shellcheck.sh
20+
description: Ensure correct syntax
21+
entry: hooks/shellcheck.sh
22+
language: script
23+
pass_filenames: true
24+
files: "^(bin|tests)/hardening/"

hooks/shellcheck.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
for script in "$@"; do
4+
/usr/bin/shellcheck --exclude=SC2317 --color=always --shell=bash -x --source-path=SCRIPTDIR "$script"
5+
done
6+
7+
exit 0

hooks/shfmt.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
for script in "$@"; do
4+
shfmt -l -i 4 -w "$script"
5+
done
6+
7+
exit 0

0 commit comments

Comments
 (0)