Set up shfmt
This commit is contained in:
parent
769d7da9b2
commit
5dbb6aea8f
4 changed files with 16 additions and 6 deletions
|
|
@ -25,7 +25,10 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
assert_fails() {
|
assert_fails() {
|
||||||
! "$@" || { echo "Expected command to fail, but it succeeded."; exit 1; }
|
! "$@" || {
|
||||||
|
echo "Expected command to fail, but it succeeded."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export -f assert_fails
|
export -f assert_fails
|
||||||
|
|
||||||
|
|
@ -42,9 +45,9 @@ for commit_hash in "${commits[@]}"; do
|
||||||
git -c advice.detachedHead=false checkout -q "$commit_hash"
|
git -c advice.detachedHead=false checkout -q "$commit_hash"
|
||||||
commit_msg="$(git log -1 --format=%B "$commit_hash")"
|
commit_msg="$(git log -1 --format=%B "$commit_hash")"
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
block="$(printf '%s\n' "$commit_msg" \
|
block="$(printf '%s\n' "$commit_msg" |
|
||||||
| sed -n '/^```git-check-assertions[[:space:]]*$/,/^```[[:space:]]*$/p' \
|
sed -n '/^```git-check-assertions[[:space:]]*$/,/^```[[:space:]]*$/p' |
|
||||||
| sed '1d;$d')"
|
sed '1d;$d')"
|
||||||
if [ -n "$block" ]; then
|
if [ -n "$block" ]; then
|
||||||
echo "git-check-assertions block in $commit_hash:"
|
echo "git-check-assertions block in $commit_hash:"
|
||||||
printf '%s\n' "$block" | sed 's/^/> /'
|
printf '%s\n' "$block" | sed 's/^/> /'
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
shellcheck-minimal,
|
shellcheck-minimal,
|
||||||
gitMinimal,
|
gitMinimal,
|
||||||
resholve,
|
resholve,
|
||||||
|
shfmt,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -20,6 +21,7 @@ resholve.mkDerivation {
|
||||||
src = fs.toSource {
|
src = fs.toSource {
|
||||||
root = ./.;
|
root = ./.;
|
||||||
fileset = fs.unions [
|
fileset = fs.unions [
|
||||||
|
./.editorconfig
|
||||||
./bin
|
./bin
|
||||||
./test
|
./test
|
||||||
];
|
];
|
||||||
|
|
@ -33,11 +35,13 @@ resholve.mkDerivation {
|
||||||
shellcheck-minimal
|
shellcheck-minimal
|
||||||
bats
|
bats
|
||||||
gitMinimal
|
gitMinimal
|
||||||
|
shfmt
|
||||||
];
|
];
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
shellcheck bin/git-check-assertions test/git-check-assertions.bats
|
shellcheck bin/git-check-assertions test/git-check-assertions.bats
|
||||||
|
shfmt -d bin/git-check-assertions test/git-check-assertions.bats
|
||||||
./test/git-check-assertions.bats
|
./test/git-check-assertions.bats
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@
|
||||||
{
|
{
|
||||||
packages.default = pkgs.callPackage ./default.nix { };
|
packages.default = pkgs.callPackage ./default.nix { };
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs; [ bats ];
|
packages = with pkgs; [
|
||||||
|
bats
|
||||||
|
shfmt
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue