Skip to content

Instantly share code, notes, and snippets.

@vipyne
Created May 22, 2020 23:16
Show Gist options
  • Save vipyne/b382259aebb33081a0fb766c1175976c to your computer and use it in GitHub Desktop.
Save vipyne/b382259aebb33081a0fb766c1175976c to your computer and use it in GitHub Desktop.
commit-msg git hook for @daily-co/daily-js - enforces conventional commit message syntax (add to .git/hooks/ in local repo)
#!/bin/sh
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
function reject()
{
echo
echo ">>> Seems like this commit message isn't conventional <<<"
echo
cat << EOF
And while we applaud your distinctive spirit, please
begin your commit message with one of the following options
(so it will show up in CHANGELOG.md):
- feat (new feature)
- fix (bug fix)
- docs (changes to documentation)
- style (formatting, missing semicolons, etc; no code change)
- refactor (refactoring production code)
- test (adding missing tests, refactoring tests; no production code change)
- chore
ie.
feat(sfu switch): Add ability to switch between p2p and sfu modes
chore(bump dependency): Update sentry
refactor(embedUtil): Rename maybeStartCamera to callMeMaybeStartCamera
for more examples, see:
https://github.com/AraBlocks/ara-module-template/blob/master/.github/COMMIT_FORMAT_EXAMPLES.md
https://github.com/AraBlocks/ara-module-template/blob/master/.github/COMMIT_FORMAT.md
for more info, see:
https://www.conventionalcommits.org/en/v1.0.0-beta.4/
EOF
echo
exit 1
}
msg=$(cat "$COMMIT_MSG_FILE")
actions=(feat fix docs style refactor test chore release)
# not very robust check for conventional commit syntax
action=$(echo "$msg" |cut -d: -f1 |cut -d\( -f1|cut -d' ' -f1| tr -d " ")
if [[ "${actions[@]}" =~ "${action}" ]]; then
echo YAY noice commit message
else
reject
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment