Skip to content

Commit

Permalink
feat: detect commit message spec automatically
Browse files Browse the repository at this point in the history
Merged commits below into one:

* feat: add commitlint configuration and husky hooks
* ci: update PR check workflow to fetch full history
* refactor: clean up husky scripts and update commitlint configuration
* chore: remove cz-conventional-changelog dependency
* chore: update husky prepare script and remove commit script
* chore: remove useless whitespaces
* chore: remove commitizen related stuff

---------

Co-authored-by: Ourai L. <[email protected]>
  • Loading branch information
huzhengen and ourai authored Jan 26, 2025
1 parent c0848ea commit f3ec122
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set node
uses: actions/setup-node@v4
Expand All @@ -24,3 +26,10 @@ jobs:

- name: Lint
run: nr lint

# 检查提交信息
- name: Lint commit messages
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
# 检查 PR 中的所有提交信息是否符合规范
# base.sha 是 PR 的起始点
# head.sha 是 PR 的最新提交
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit ${1}
29 changes: 29 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'chore',
'revert',
'ci',
'build',
'test',
],
],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'scope-case': [2, 'always', 'lower-case'],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'header-max-length': [2, 'always', 72],
},
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
"@astrojs/starlight": "0.28.5",
"@astrojs/starlight-tailwind": "2.0.3",
"@astrojs/tailwind": "5.1.2",
"@commitlint/cli": "19.6.1",
"@commitlint/config-conventional": "19.6.0",
"@knosys/sdk": "^0.0.3",
"@tailwindcss/line-clamp": "0.4.4",
"@types/node": "18.11.3",
Expand Down

0 comments on commit f3ec122

Please sign in to comment.