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 = {
|
||||
packages = with pkgs;
|
||||
[
|
||||
Fmt
|
||||
nodePackages.prettier
|
||||
shfmt
|
||||
bob-nvim
|
||||
@ -236,7 +237,7 @@ in {
|
||||
};
|
||||
git = {
|
||||
enable = true;
|
||||
hooks = { pre-commit = ../scripts/check-fmt-git-files.bash; };
|
||||
hooks = { pre-commit = ../scripts/check-fmt-git-pre-commit.bash; };
|
||||
userName = "Price Hiller";
|
||||
userEmail = "price@orion-technologies.io";
|
||||
aliases = { unstage = "reset HEAD --"; };
|
||||
|
@ -41,7 +41,7 @@
|
||||
defaultPackage.x86_64-linux = home-manager.defaultPackage.x86_64-linux;
|
||||
targets.genericLinux = { enable = true; };
|
||||
homeConfigurations.${username} =
|
||||
home-manager.lib.homeManagerConfiguration {
|
||||
home-manager.lib.homeManagerConfiguration rec {
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
@ -57,6 +57,7 @@
|
||||
inputs.kanagawa-gtk.overlays.default
|
||||
inputs.nixgl.overlay
|
||||
(final: prev: {
|
||||
Fmt = pkgs.writeScriptBin "Fmt" (builtins.readFile ./scripts/fmt.bash);
|
||||
waybar = inputs.waybar.packages.${system}.default;
|
||||
lxappearance = prev.lxappearance.overrideAttrs (oldAttrs: {
|
||||
postInstall = ''
|
||||
|
@ -16,7 +16,7 @@ main() {
|
||||
fi
|
||||
done < <(git ls-tree --full-name --full-tree --name-only -r HEAD)
|
||||
|
||||
"${root}/scripts/fmt.bash" -- "${files[@]}"
|
||||
Fmt -- "${files[@]}"
|
||||
}
|
||||
|
||||
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