summaryrefslogtreecommitdiff
path: root/scripts/commit.sh
blob: 50ce5fae563cabbd22b31e76247d5e063d5adbd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash

set -e

if git diff --cached --quiet; then
    echo "No staged changes."
    exit 1
fi

MSG=$(git diff --cached | ollama run git-commit)

echo
echo "Generated commit message:"
echo "$MSG"
echo

read -p "Commit? [Y/n] " CONFIRM

if [[ "$CONFIRM" =~ ^[Nn]$ ]]; then
    exit 0
fi

git commit -m "$MSG"