Skip to content

Conversation

@alexhancock
Copy link
Collaborator

Automatically verify commits follow the https://www.conventionalcommits.org/en/v1.0.0/ format.

We get a lot of PRs with commits that do not follow the format, and it creates unnecessary cycles during code review. This PR installs a pre-commit hook on the first cargo build and then uses it when you commit.

Example:

13:09:41 ~/Development/rust-sdk alexhancock/pre-commit-lint* $ git commit -am "something invalid"
ERROR: Commit message does not follow conventional commit format.

Expected format: <type>(<scope>): <description>

Valid types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test

Examples:
  feat: add new feature
  fix(parser): resolve parsing issue
  docs: update README

Your commit message:
  something invalid

jamadeo
jamadeo previously approved these changes Jan 14, 2026
Copy link
Collaborator

@jamadeo jamadeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yes this will improve things.

Looks like CI calls npx commitlint -- should this do the same?

@alexhancock
Copy link
Collaborator Author

@jamadeo I tried a version that does that but if we want to do local packages it would require adding package.json, assuming a node installation etc. It added a lot more boilerplate to the project.

There is maybe a version of that approach which just uses npx and doesn't do the linting if it's not available. I'll spike on that as it would be good to have the consistency.

@alexhancock
Copy link
Collaborator Author

@jamadeo Came up with a better version which uses commitlint if node is available, and falls back to a more basic implementation if not.

@alexhancock alexhancock requested a review from jamadeo January 14, 2026 20:46
@alexhancock alexhancock merged commit 9b629c6 into main Jan 14, 2026
11 checks passed
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

Successfully merging this pull request may close these issues.

3 participants