feat: add check-fmt-pre-commit.bash to git hooks
Some checks failed
Check Formatting of Files / Check-Formatting (push) Failing after 25s
Some checks failed
Check Formatting of Files / Check-Formatting (push) Failing after 25s
This commit is contained in:
parent
8ec34c10ee
commit
78b3796e68
@ -28,6 +28,7 @@ in {
|
|||||||
home = {
|
home = {
|
||||||
packages = with pkgs;
|
packages = with pkgs;
|
||||||
[
|
[
|
||||||
|
Fmt
|
||||||
nodePackages.prettier
|
nodePackages.prettier
|
||||||
shfmt
|
shfmt
|
||||||
bob-nvim
|
bob-nvim
|
||||||
@ -236,7 +237,7 @@ in {
|
|||||||
};
|
};
|
||||||
git = {
|
git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hooks = { pre-commit = ../scripts/check-fmt-git-files.bash; };
|
hooks = { pre-commit = ../scripts/check-fmt-git-pre-commit.bash; };
|
||||||
userName = "Price Hiller";
|
userName = "Price Hiller";
|
||||||
userEmail = "price@orion-technologies.io";
|
userEmail = "price@orion-technologies.io";
|
||||||
aliases = { unstage = "reset HEAD --"; };
|
aliases = { unstage = "reset HEAD --"; };
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
defaultPackage.x86_64-linux = home-manager.defaultPackage.x86_64-linux;
|
defaultPackage.x86_64-linux = home-manager.defaultPackage.x86_64-linux;
|
||||||
targets.genericLinux = { enable = true; };
|
targets.genericLinux = { enable = true; };
|
||||||
homeConfigurations.${username} =
|
homeConfigurations.${username} =
|
||||||
home-manager.lib.homeManagerConfiguration {
|
home-manager.lib.homeManagerConfiguration rec {
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
@ -57,6 +57,7 @@
|
|||||||
inputs.kanagawa-gtk.overlays.default
|
inputs.kanagawa-gtk.overlays.default
|
||||||
inputs.nixgl.overlay
|
inputs.nixgl.overlay
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
|
Fmt = pkgs.writeScriptBin "Fmt" (builtins.readFile ./scripts/fmt.bash);
|
||||||
waybar = inputs.waybar.packages.${system}.default;
|
waybar = inputs.waybar.packages.${system}.default;
|
||||||
lxappearance = prev.lxappearance.overrideAttrs (oldAttrs: {
|
lxappearance = prev.lxappearance.overrideAttrs (oldAttrs: {
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
|
@ -16,7 +16,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
done < <(git ls-tree --full-name --full-tree --name-only -r HEAD)
|
done < <(git ls-tree --full-name --full-tree --name-only -r HEAD)
|
||||||
|
|
||||||
"${root}/scripts/fmt.bash" -- "${files[@]}"
|
Fmt -- "${files[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main "${@}"
|
main "${@}"
|
||||||
|
22
scripts/check-fmt-git-pre-commit.bash
Normal file
22
scripts/check-fmt-git-pre-commit.bash
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env -S nix --extra-experimental-features "flakes nix-command" shell nixpkgs#bash nixpkgs#git --command bash
|
||||||
|
# vim: ft=sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local root
|
||||||
|
root="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
local files=()
|
||||||
|
|
||||||
|
while IFS= read -r file; do
|
||||||
|
local fpath="${root}/${file}"
|
||||||
|
if [[ -r "${fpath}" ]]; then
|
||||||
|
files+=("${fpath}")
|
||||||
|
fi
|
||||||
|
done < <(git diff --name-only --staged --diff-filter=d)
|
||||||
|
|
||||||
|
Fmt -- "${files[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
Loading…
Reference in New Issue
Block a user