github.com/status-im/status-go@v1.1.0/_assets/scripts/parse_commits.sh (about) 1 #!/usr/bin/env bash 2 3 # The output of this script is as follows: 4 # 1. One line "checking commits between: <start_commit> <end_commit>" 5 # 2. One line for each commit message that is not well-formed 6 # 3. One line with the value of "is_breaking_change" (true/false) 7 8 set -euo pipefail 9 10 source _assets/scripts/colors.sh 11 12 parse_commits() { 13 14 BASE_BRANCH=${BASE_BRANCH:-develop} 15 16 start_commit=${1:-origin/${BASE_BRANCH}} 17 end_commit=${2:-HEAD} 18 is_breaking_change=false 19 exit_code=0 20 21 echo -e "${GRN}Checking commits between:${RST} $start_commit $end_commit" 22 # Run the loop in the current shell using process substitution 23 while IFS= read -r message || [ -n "$message" ]; do 24 # Check if commit message follows conventional commits format 25 if [[ $message =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(\_|!):.*$ ]]; then 26 # Check for breaking changes 27 if [[ ${BASH_REMATCH[3]} == *'!'* ]]; then 28 is_breaking_change=true 29 fi 30 else 31 echo -e "${YLW}Commit message is ill-formed:${RST} $message" 32 exit_code=1 33 fi 34 done < <(git log --format=%s "$start_commit".."$end_commit") 35 36 echo "$is_breaking_change" 37 exit ${exit_code} 38 }