diff --git a/.commitlintrc.mjs b/.commitlintrc.mjs index 2337e7e..52e6c21 100644 --- a/.commitlintrc.mjs +++ b/.commitlintrc.mjs @@ -19,6 +19,8 @@ export default { 'ui', 'wip', 'publish', + 'docker', + 'WIP', ], ], }, diff --git a/.husky/append-icon.sh b/.husky/append-icon.sh index 8990b55..a54594a 100755 --- a/.husky/append-icon.sh +++ b/.husky/append-icon.sh @@ -23,41 +23,43 @@ function checkBreakingChangeInBody() { } function findTypeIcon() { - # get message from 1st param message="$1" - # declare an icons for each authorized enum-type from `.commitlintrc.js` - declare -A icons - icons[build]='๐Ÿค–' - icons[chore]='๐Ÿงน' - icons["chore(deps)"]='๐Ÿงน' - icons[config]='๐Ÿ”ง' - icons[deploy]='๐Ÿš€' - icons[doc]='๐Ÿ“š' - icons[feat]='โœจ' - icons[fix]='๐Ÿ›' - icons[hotfix]='๐Ÿš‘' - icons[i18n]='๐Ÿ’ฌ' - icons[publish]='๐Ÿ“ฆ' - icons[refactor]='โšก' - icons[revert]='โช' - icons[test]='โœ…' - icons[ui]='๐ŸŽจ' - icons[wip]='๐Ÿšง' - icons[WIP]='๐Ÿšง' + if [[ "$message" =~ ^.*!:\ .* ]]; then + echo "$boomIcon" + return 0 + fi - for type in "${!icons[@]}"; do - # check if message subject contains breaking change pattern - if [[ "$message" =~ ^(.*)(!:){1}(.*)$ ]]; then - echo "$boomIcon" - return 0 - # else find corresponding type icon - elif [[ "$message" == "$type"* ]]; then - echo "${icons[$type]}" - return 0 - fi - done - return 1 + declare -A icons=( + [build]='๐Ÿค–' + [chore]='๐Ÿงน' + ["chore(deps)"]='๐Ÿงน' + [config]='๐Ÿ”ง' + [deploy]='๐Ÿš€' + [doc]='๐Ÿ“š' + [feat]='โœจ' + [fix]='๐Ÿ›' + [hotfix]='๐Ÿš‘' + [i18n]='๐Ÿ’ฌ' + [publish]='๐Ÿ“ฆ' + [refactor]='โšก' + [revert]='โช' + [test]='โœ…' + [ui]='๐ŸŽจ' + [wip]='๐Ÿšง' + [WIP]='๐Ÿšง' + [docker]='๐Ÿณ' + ) + + commit_type="${message%%:*}" + + icon="${icons[$commit_type]}" + if [[ -n "$icon" ]]; then + echo "$icon" + return 0 + else + return 1 + fi } # extract original message from the first line of file