dsh-commit-msg-check 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/index.js +6 -1
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Commit-message hygiene from a single message. A commit is decidable: it has a **type prefix** from a known set, a **subject that fits a git log line**, a **blank line before the body**, and **breaking changes announced in a trailer** rather than buried in the subject. This verifies exactly those — one file, no git history needed.
|
|
4
4
|
|
|
5
|
+
## 前置要求
|
|
6
|
+
|
|
7
|
+
Node.js ≥ 22.19,就是 `package.json` 里 `engines.node` 写的那一条;CLI 只依赖 Node,别的不装也能跑。想在对话里用同一个检查,需要 DSH `>=0.2.2-rc.1 <0.3.0-0`。装之前 `node -v` 看一眼,比装完再猜为什么报错快。
|
|
8
|
+
|
|
9
|
+
跑通大概 2 分钟。卡住了在仓库开 issue,别自己啃。
|
|
10
|
+
|
|
5
11
|
<!-- example:start -->
|
|
6
12
|
## 真实输入输出
|
|
7
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-commit-msg-check",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Commit-message hygiene from a single message: a type prefix from a known set, a subject that fits a git log line, no trailing period, a blank line before the body, and breaking changes announced in a trailer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/index.js
CHANGED
|
@@ -24,7 +24,12 @@ export const TYPES = ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test'
|
|
|
24
24
|
|
|
25
25
|
// `type(scope): subject` or `type: subject`. The colon is required; a bare
|
|
26
26
|
// sentence with no prefix is the most common violation and the cheapest to fix.
|
|
27
|
-
|
|
27
|
+
//
|
|
28
|
+
// The subject is `.*`, not `.+`, on purpose: with `.+` a header of `feat:` fails
|
|
29
|
+
// to parse, so `type` reads as null and the `subject-empty` rule below can never
|
|
30
|
+
// fire. It was dead code until the rules audit looked for a test that makes each
|
|
31
|
+
// rule fire and found none for this one.
|
|
32
|
+
const HEADER = /^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.*)$/
|
|
28
33
|
|
|
29
34
|
export function parseCommit(text) {
|
|
30
35
|
const lines = String(text).split('\n')
|