feat(scripts): add prepare-commit-msg hook installation script
All checks were successful
Flake checker / Build Nix targets (push) Successful in 9m26s

This commit is contained in:
uttarayan21
2025-08-20 01:18:27 +05:30
parent c990dc60cd
commit 0c35e52136
2 changed files with 26 additions and 0 deletions

View File

@@ -32,6 +32,14 @@ in {
exec $EDITOR "$1"
'';
})
(
pkgs.writeShellApplication {
name = "git-install-prepare-commit-msg";
text = ''
cp ${../scripts/prepare-commit-msg} .git/hooks/prepare-commit-msg
'';
}
)
(mkScript ../scripts/yt-dlp.sh (with pkgs; [yt-dlp]))
(mkScript ../scripts/autossh.sh (with pkgs; [autossh openssh]))
];

18
scripts/prepare-commit-msg Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
if [[ -z "$COMMIT_SOURCE" ]]
then
DIFF_OUTPUT=$(git diff --cached)
AI_CHAT_OUTPUT=$(echo "$DIFF_OUTPUT" | aichat --role %git-commit%)
CURRENT_MSG=$(cat "$COMMIT_MSG_FILE")
{
echo "$AI_CHAT_OUTPUT"
echo
echo "$CURRENT_MSG"
} > "$COMMIT_MSG_FILE"
fi