forked from Kaaveh/ComposeNews
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kaaveh#245 from VahidGarousi/240-verify-that-a-com…
…mit-message-contains-issue-number-with-pre-commit-hook Verify that a commit message contains issue number with pre commit hook
- Loading branch information
Showing
8 changed files
with
226 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Path to the commit message file | ||
commit_msg_file="$1" | ||
|
||
# Regular expression to match issue numbers starting with # | ||
# Examples: #123, [#123] | ||
issue_pattern="(\[#?[0-9]+\]|#?[0-9]+)" | ||
|
||
# Read the commit message | ||
commit_msg=$(cat "$commit_msg_file") | ||
|
||
echo "Validating commit message..." | ||
echo "Debug: Commit message is: '$commit_msg'" | ||
|
||
# Validate commit message | ||
if ! echo "$commit_msg" | grep -qE "$issue_pattern"; then | ||
echo "❌ Commit message validation failed!" | ||
echo "👉 Your commit message must include an issue number starting with # (e.g., #123 or [#123])." | ||
echo "" | ||
echo "Examples:" | ||
echo " ✅ Fix bug in login flow #123" | ||
echo " ✅ [#456] Refactor login module" | ||
echo " ✅ Add tests for API #789" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Commit message validation passed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!C:/Program\ Files/Git/usr/bin/sh.exe | ||
|
||
# Path to the commit message file | ||
commit_msg_file="$1" | ||
|
||
# Regular expression to match issue numbers starting with # | ||
# Examples: #123, [#123] | ||
issue_pattern="(\[#?[0-9]+\]|#?[0-9]+)" | ||
|
||
# Read the commit message | ||
commit_msg=$(cat "$commit_msg_file") | ||
|
||
echo "Validating commit message..." | ||
echo "Debug: Commit message is: '$commit_msg'" | ||
|
||
# Validate commit message | ||
if ! echo "$commit_msg" | grep -qE "$issue_pattern"; then | ||
echo "❌ Commit message validation failed!" | ||
echo "👉 Your commit message must include an issue number starting with # (e.g., #123 or [#123])." | ||
echo "" | ||
echo "Examples:" | ||
echo " ✅ Fix bug in login flow #123" | ||
echo " ✅ [#456] Refactor login module" | ||
echo " ✅ Add tests for API #789" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Commit message validation passed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
|
||
######## KTLINT-GRADLE HOOK START ######## | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!C:/Program\ Files/Git/usr/bin/sh.exe | ||
|
||
######## KTLINT-GRADLE HOOK START ######## | ||
|
||
CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.kts|\.kt/ { print $2}')" | ||
|
||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No Kotlin staged files." | ||
exit 0 | ||
fi; | ||
|
||
echo "Running ktlint over these files:" | ||
echo "$CHANGED_FILES" | ||
|
||
./gradlew --quiet formatKotlin -PinternalKtlintGitFilter="$CHANGED_FILES" | ||
|
||
echo "Completed ktlint run." | ||
|
||
echo "$CHANGED_FILES" | while read -r file; do | ||
if [ -f $file ]; then | ||
git add $file | ||
fi | ||
done | ||
|
||
echo "Completed ktlint hook." | ||
######## KTLINT-GRADLE HOOK END ######## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
echo "Running static analysis." | ||
|
||
./gradlew lintKotlin | ||
./gradlew detekt | ||
echo "Running static analysis completed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!C:/Program\ Files/Git/usr/bin/sh.exe | ||
|
||
echo "Running static analysis." | ||
|
||
./gradlew lintKotlin | ||
./gradlew detekt | ||
echo "Running static analysis completed" |
This file was deleted.
Oops, something went wrong.