-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·71 lines (65 loc) · 1.76 KB
/
Copy pathcommit.sh
File metadata and controls
executable file
·71 lines (65 loc) · 1.76 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
#!/bin/sh
REPO="libershare.git"
NAME="LiberSoft"
BRANCH="main"
EMAIL="info@libersoft.org"
USER="libersoft-org"
PASS=$(cat ./.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 prettier-plugin-svelte
./prettier-all.sh
git config user.name "$NAME"
git config user.email "$EMAIL"
git status
git add .
git status
if [ "$#" -eq 0 ]; then
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
} | copilot -s --no-ask-user 2>/dev/null)
if [ -z "$COMMIT_MSG" ] || [ "$COMMIT_MSG" = "No changes" ]; then
echo "\033[31mERROR:\033[0m Failed to generate commit message. Please provide one manually:"
echo "Usage: $0 \"[COMMIT MESSAGE]\""
exit 1
fi
# Clean the commit message - remove quotes and sanitize
COMMIT_MSG=$(echo "$COMMIT_MSG" | sed 's/"//g' | sed "s/'//g")
echo "\033[33mGENERATED COMMIT MESSAGE:\033[0m $COMMIT_MSG"
COMMIT_MESSAGE="$COMMIT_MSG"
else
# Sanitize user-provided message
COMMIT_MESSAGE=$(echo "$1" | sed 's/"//g' | sed "s/'//g")
fi
git commit -m "$COMMIT_MESSAGE"
git push
git status