-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[docs]: update README.md #1615
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
Closed
Closed
[docs]: update README.md #1615
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| ## Before Commit! | ||
|
|
||
| Your commit message must follow Conventional Commits (https://www.conventionalcommits.org/) and your code should be formatted. The Git hooks will do most of the work automatically: | ||
|
|
||
| ### Tool Requirements | ||
|
|
||
| You need a recent `clang-format` (>= 18). In a conda environment you can install: | ||
|
|
||
| ```shell | ||
| conda install -c conda-forge clang-format=18 | ||
| ``` | ||
|
|
||
| If you previously configured with an older version, remove the build directory and reconfigure: | ||
|
|
||
| ```shell | ||
| rm -rf kt-kernel/build | ||
| ``` | ||
|
|
||
| Install `black` for Python formatting: | ||
|
|
||
| ```shell | ||
| conda install black | ||
| ``` | ||
|
|
||
| ### Install hook: | ||
| ```shell | ||
| bash kt-kernel/scripts/install-git-hooks.sh | ||
| #or just cmake the kt-kernel | ||
| cmake -S kt-kernel -B kt-kernel/build | ||
| ``` | ||
|
|
||
| There are manual commands if you need format. | ||
|
|
||
| ```shell | ||
| cmake -S kt-kernel -B kt-kernel/build | ||
| cmake --build kt-kernel/build --target format | ||
| ``` | ||
|
|
||
| ## Developer Note | ||
|
|
||
| Formatting and commit message rules are enforced by Git hooks. After installing `clang-format` and `black`, just commit normally—the hooks will run formatting for you. | ||
|
|
||
| > [!NOTE] | ||
| > If formatting modifies files, the commit is aborted after staging those changes. Review them and run `git commit` again. Repeat until no further formatting changes appear. | ||
|
|
||
| --- | ||
|
|
||
| ### Conventional Commit Regex (Reference) | ||
|
|
||
| The commit-msg hook enforces this pattern: | ||
|
|
||
| ```text | ||
| regex='^\[(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|wip)\](\([^\)]+\))?(!)?: .+' | ||
| ``` | ||
|
|
||
| Meaning (English): | ||
| * `[type]` required — one of feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|wip | ||
| * Optional scope: `(scope)` — any chars except `)` | ||
| * Optional breaking change marker: `!` right after type or scope | ||
| * Separator: `: ` (colon + space) | ||
| * Subject: free text (at least one character) | ||
|
|
||
| Examples: | ||
| ```text | ||
| [feat]: add adaptive batching | ||
| [fix(parser)]: handle empty token list | ||
| [docs]!: update API section for breaking rename | ||
| ``` | ||
|
|
||
| You can bypass locally (not recommended) with: | ||
| ```shell | ||
| git commit --no-verify | ||
| ``` | ||
| ## 提交前提醒 | ||
|
|
||
| 提交信息必须满足 Conventional Commits 规范 (https://www.conventionalcommits.org/),代码需要符合格式要求。Git 钩子已经集成了大部分工作: | ||
| ### 软件要求 | ||
|
|
||
| 需要较新的 `clang-format` (>= 18),在 conda 环境中安装: | ||
|
|
||
| ```shell | ||
| conda install -c conda-forge clang-format=18 | ||
| ``` | ||
|
|
||
| 如果之前用老版本配置过,请删除构建目录重新配置: | ||
|
|
||
| ```shell | ||
| rm -rf kt-kernel/build | ||
| ``` | ||
|
|
||
| 安装 `black` 以进行 Python 文件格式化: | ||
|
|
||
| ```shell | ||
| conda install black | ||
| ``` | ||
| ### 安装钩子 | ||
| ```shell | ||
| bash kt-kernel/scripts/install-git-hooks.sh | ||
| #or just cmake the kt-kernel | ||
| cmake -S kt-kernel -B kt-kernel/build | ||
| ``` | ||
| 如果你需要手动格式化: | ||
| ```shell | ||
| cmake -S kt-kernel -B kt-kernel/build | ||
| cmake --build kt-kernel/build --target format | ||
| ``` | ||
|
|
||
| ## 开发者说明 | ||
|
|
||
| 本仓库通过 Git hooks 自动执行代码格式化与提交信息规范检查。只需安装好 `clang-format` 与 `black` 后正常执行提交即可,钩子会自动格式化。 | ||
|
|
||
| > [!NOTE] | ||
| > 如果格式化修改了文件,钩子会终止提交并已暂存这些改动。请查看修改后再次执行 `git commit`,重复直到没有新的格式化变更。 | ||
|
|
||
| ### 提交信息正则(参考) | ||
|
|
||
| 钩子使用如下正则检查提交信息: | ||
| ```text | ||
| regex='^\[(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|wip)\](\([^\)]+\))?(!)?: .+' | ||
| ``` | ||
| 含义: | ||
| * `[type]` 必填:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|wip | ||
| * 作用域可选:`(scope)`,不能包含右括号 | ||
| * 可选的破坏性标记:`!` | ||
| * 分隔符:冒号+空格 `: ` | ||
| * 描述:至少一个字符 | ||
|
|
||
| 示例: | ||
| ```text | ||
| [feat]: 增加自适应 batch 功能 | ||
| [fix(tokenizer)]: 修复空 token 列表处理 | ||
| [docs]!: 更新接口文档(存在破坏性修改) | ||
| ``` | ||
|
|
||
| 跳过钩子(不推荐,仅紧急时): | ||
| ```shell | ||
| git commit --no-verify | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current method of constructing
BLACK_PATHSas a space-separated string is not robust and will fail if the repository path contains spaces. The shell will perform word splitting on the unquoted$BLACK_PATHSvariable, passing incorrect paths toblack. Using a bash array to store the paths and then expanding it with"${BLACK_PATHS[@]}"ensures that each path is passed as a single, correctly quoted argument, making the script reliable for all users regardless of their directory structure.