feat(scripts): add prepare-commit-msg hook installation script
All checks were successful
Flake checker / Build Nix targets (push) Successful in 9m26s
All checks were successful
Flake checker / Build Nix targets (push) Successful in 9m26s
This commit is contained in:
@@ -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
18
scripts/prepare-commit-msg
Executable 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
|
||||
Reference in New Issue
Block a user