-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_commit_msg.sh
More file actions
33 lines (26 loc) · 1022 Bytes
/
fix_commit_msg.sh
File metadata and controls
33 lines (26 loc) · 1022 Bytes
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
#!/bin/bash
# Fix the commit message in history
cd /home/z1337/Desktop/PROJECTS/cloud-security-auditor
# Find the commit with the bad message
BAD_COMMIT=$(git log --format="%H %s" --all | grep "AI-generated lab guides" | cut -d' ' -f1)
if [ -z "$BAD_COMMIT" ]; then
echo "✅ Commit message already fixed or not found"
exit 0
fi
echo "Found bad commit: $BAD_COMMIT"
echo "Rewriting commit message..."
# Use git rebase to fix it
git rebase -i ${BAD_COMMIT}^ <<EOF
reword $BAD_COMMIT
EOF
# The rebase will open an editor, but we can use GIT_SEQUENCE_EDITOR to automate it
GIT_SEQUENCE_EDITOR="sed -i '1s/^pick/reword/'" git rebase -i ${BAD_COMMIT}^
# Actually, let's just use filter-branch one more time with proper escaping
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --msg-filter '
if echo "$GIT_COMMIT_MSG" | grep -q "AI-generated lab guides"; then
echo "Update .gitignore to exclude local documentation files"
else
cat
fi
' main
echo "✅ Done! Commit message fixed."