Skip to content

Commit 40f8030

Browse files
committed
feat: added template script for git hooks ✨
1 parent e4f0d58 commit 40f8030

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

commit-msg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Declare emojis
4+
emojis=("🏗️" "🔧" "👷" "📚" "" "🐛" "🏎" "♻️" "⏪️" "🎨" "🧪" "🚧")
5+
types=("build" "chore" "ci" "docs" "feat" "fix" "perf" "refactor" "revert" "style" "test" "wip")
6+
7+
# Get header and body from commit message
8+
header="$(head -n 1 $1)";
9+
body="$(tail -n +2 $1)";
10+
11+
# Loop through all types
12+
for key in "${!types[@]}"; do
13+
14+
# Check, if emoji is already present
15+
if [[ "$header" == *"${types[key]}"* ]] && [[ "$header" == *"${emojis[key]}"* ]]; then
16+
exit 0;
17+
fi
18+
19+
# Add emoji to commit message
20+
if [[ "$header" == *"${types[key]}"* ]] && [[ "$header" != *"${emojis[key]}"* ]]; then
21+
printf "$header ${emojis[key]}\n$body" > $1
22+
exit 0;
23+
fi
24+
25+
done

0 commit comments

Comments
 (0)