-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb150f3
commit bcaf8eb
Showing
4 changed files
with
75 additions
and
49 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 |
---|---|---|
@@ -1,36 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
parse_commits() { | ||
|
||
BASE_BRANCH=${BASE_BRANCH:-develop} | ||
|
||
start_commit=${1:-origin/${BASE_BRANCH}} | ||
end_commit=${2:-HEAD} | ||
is_breaking_change=false | ||
exit_code=0 | ||
|
||
echo "checking commits between: $start_commit $end_commit" | ||
# Run the loop in the current shell using process substitution | ||
while IFS= read -r message || [ -n "$message" ]; do | ||
# Check if commit message follows conventional commits format | ||
if [[ $message =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(\_|!):.*$ ]]; then | ||
# Check for breaking changes | ||
if [[ ${BASH_REMATCH[3]} == *'!'* ]]; then | ||
is_breaking_change=true | ||
fi | ||
else | ||
echo "Commit message \"$message\" is not well-formed" | ||
exit_code=1 | ||
fi | ||
done < <(git log --format=%s "$start_commit".."$end_commit") | ||
|
||
if [[ $exit_code -ne 0 ]]; then | ||
exit ${exit_code} | ||
fi | ||
|
||
echo "$is_breaking_change" | ||
} | ||
|
||
source _assets/scripts/parse_commits.sh | ||
parse_commits "$@" |
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,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The output of this script is as follows: | ||
# 1. One line "checking commits between: <start_commit> <end_commit>" | ||
# 2. One line for each commit message that is not well-formed | ||
# 3. One line with the value of "is_breaking_change" (true/false) | ||
|
||
set -euo pipefail | ||
|
||
source _assets/scripts/colors.sh | ||
|
||
parse_commits() { | ||
|
||
BASE_BRANCH=${BASE_BRANCH:-develop} | ||
|
||
start_commit=${1:-origin/${BASE_BRANCH}} | ||
end_commit=${2:-HEAD} | ||
is_breaking_change=false | ||
exit_code=0 | ||
|
||
echo -e "${GRN}Checking commits between:${RST} $start_commit $end_commit" | ||
# Run the loop in the current shell using process substitution | ||
while IFS= read -r message || [ -n "$message" ]; do | ||
# Check if commit message follows conventional commits format | ||
if [[ $message =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(\_|!):.*$ ]]; then | ||
# Check for breaking changes | ||
if [[ ${BASH_REMATCH[3]} == *'!'* ]]; then | ||
is_breaking_change=true | ||
fi | ||
else | ||
echo -e "${YLW}Commit message is not well-formed:${RST} \"$message\"" | ||
exit_code=1 | ||
fi | ||
done < <(git log --format=%s "$start_commit".."$end_commit") | ||
|
||
echo "$is_breaking_change" | ||
exit ${exit_code} | ||
} |
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