-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·86 lines (74 loc) · 2.39 KB
/
Copy pathcommit.sh
File metadata and controls
executable file
·86 lines (74 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
REPO="libersystem.git"
NAME="LiberSoft"
BRANCH="main"
EMAIL="info@libersoft.org"
USER="libersoft-org"
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
cd "$ROOT"
PASS=$(<"$ROOT/.secret_git")
if [ ! -d "./.git/" ]; then
git init
git config --global --add safe.directory '*'
git remote add origin https://$USER:$PASS@github.com/$USER/$REPO
else
git remote set-url origin https://$USER:$PASS@github.com/$USER/$REPO
fi
bun i -g prettier
git config user.name "$NAME"
git config user.email "$EMAIL"
if ! "$ROOT/format.sh" --changed; then
echo "commit.sh: formatting changed files failed - committing without a fresh format pass"
fi
git status
git add .
src/tools/check-source-hygiene.sh --added
git status
if [ "$#" -eq 0 ]; then
echo "Generating commit message using Claude Code..."
# echo "Generating commit message using GitHub Copilot..."
COMMIT_MSG=$({
echo "Write exactly one Git commit subject."
echo "Max 250 characters."
echo "One line only."
echo "No prefix."
echo "No markdown."
echo "No bullets."
echo "No explanation."
echo "No status narration."
echo "If there are no changes, write exactly: No changes"
echo
echo "GIT STATUS:"
git status --short
echo
echo "STAGED DIFF STAT:"
git diff --cached --stat
echo
echo "STAGED DIFF:"
git diff --cached --unified=0
echo
echo "UNSTAGED DIFF STAT:"
git diff --stat
echo
echo "UNSTAGED DIFF:"
git diff --unified=0
} | claude -p --model haiku --output-format text --no-session-persistence \
--system-prompt "You output exactly one line of plain text and nothing else. Never use markdown, code fences, backticks, bullets, headings or commentary." \
--disallowedTools Bash Read Glob Grep Edit Write WebFetch WebSearch Task TodoWrite 2>/dev/null |
sed -e 's/`//g' -e '/^[[:space:]]*$/d' | head -n 1)
# Previous generator (GitHub Copilot CLI), kept for reference:
# } | copilot -s --no-ask-user 2>/dev/null)
if [ -z "$COMMIT_MSG" ] || [ "$COMMIT_MSG" = "No changes" ]; then
printf '\033[31mERROR:\033[0m Failed to generate commit message. Please provide one manually:\n'
echo "Usage: $0 \"[COMMIT MESSAGE]\""
exit 1
fi
COMMIT_MSG=$(echo "$COMMIT_MSG" | sed 's/"//g' | sed "s/'//g")
printf '\033[33mGENERATED COMMIT MESSAGE:\033[0m %s\n' "$COMMIT_MSG"
COMMIT_MESSAGE="$COMMIT_MSG"
else
COMMIT_MESSAGE=$(echo "$1" | sed 's/"//g' | sed "s/'//g")
fi
git commit -m "$COMMIT_MESSAGE"
git push
git status