Skip to content

Commit

Permalink
chore: add back conventinal commits check
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Apr 16, 2023
1 parent 4d0c390 commit cce002e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

flag_file_path='.version-update'

if [ -f $flag_file_path ]; then
Expand Down
27 changes: 14 additions & 13 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@ if [ -f $flag_file_path ]; then
exit 0
fi

if [ ! $(git branch --show-current) = 'main' ]; then
if [ $(git branch --show-current) != 'main' ]; then
exit 0
fi

# types
commit_types='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)'
minor_types='^(build|feat|revert)'
patch_types='^(chore|fix|perf|refactor)'

parens='(\(\w+\))?'
msg=':\s.+'
opt_exclam='!?'
exclam='!'

commit_types='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)'$parens
minor_types='^(build|feat|revert)'$parens$msg
patch_types='^(chore|fix|perf|refactor)'$parens$msg

version_match='"version": *"[0-9.]\+"'
version_str='"version": '

# read message to var
commit_msg=$(cat $1)

# TODO: fix this, as it does not work...
#if [[ $commit_msg =~ $commit_types$parens'!?'$msg ]]; then
# echo 'Use Conventional Commits: https://conventionalcommits.org'
# exit 1
#fi
if ! [[ $commit_msg =~ $commit_types$opt_exclam$msg ]]; then
echo 'Use Conventional Commits: https://conventionalcommits.org'
exit 1
fi

# bump version function
bumpVersion() {
Expand All @@ -42,13 +43,13 @@ bumpVersion() {
}

# version change type
if [[ $commit_msg =~ $commit_types$parens'!'$msg ]]; then
if [[ $commit_msg =~ $commit_types$exclam$msg ]]; then
bumpVersion major
else
if [[ $commit_msg =~ $minor_types$parens$msg ]]; then
if [[ $commit_msg =~ $minor_types ]]; then
bumpVersion minor
else
if [[ $commit_msg =~ $patch_types$parens$msg ]]; then
if [[ $commit_msg =~ $patch_types ]]; then
bumpVersion patch
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Replace Maps iframes with OSM",
"author": "nobkd",
"license": "Unlicense",
"version": "1.1.3",
"version": "1.1.4",
"type": "module",
"homepage": "https://github.com/nobkd/replace-maps#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "Replace Maps iframes with OSM",
"manifest_version": 2,
"name": "Replace Maps",
"version": "1.1.3",
"version": "1.1.4",
"homepage_url": "https://github.com/nobkd/replace-maps",
"icons": {
"48": "icons/48.png",
Expand Down

0 comments on commit cce002e

Please sign in to comment.