Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commitlint #110

Closed
binjospookie opened this issue Feb 3, 2020 · 3 comments
Closed

Commitlint #110

binjospookie opened this issue Feb 3, 2020 · 3 comments

Comments

@binjospookie
Copy link

Hi!
I want to use Lefthook with Commitlint on pre-commit.
In Commitlint's docs I found "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" (https://github.com/conventional-changelog/commitlint#getting-started). But Lefthook hasn't HUSKY_GIT_PARAMS of course :)

What should I do to solve this problem?

@Arkweid
Copy link
Collaborator

Arkweid commented Feb 3, 2020

Try it like usual executable you have:

commit-msg:
  commands:
    commitlint:
      run: echo "wololo" | commitlint

Or try it just like script:
https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md#bash-script-example

@binjospookie
Copy link
Author

Thank you! I'll try and update this issue with new information.

@binjospookie
Copy link
Author

I modify your script with type-enum from https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum

Looks like:

INPUT_FILE=$1
START_LINE=`head -n1 $INPUT_FILE`
PATTERN="^(build|ci|docs|feat|fix|perf|refactor|revert|style|test)+: "
if ! [[ "$START_LINE" =~ $PATTERN ]]; then
  echo -e "Invalid commit message.\nCommit message must start with '(build|ci|docs|feat|fix|perf|refactor|revert|style|test):'"
  exit 1
fi

Thank you for help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants