@itcase/config 1.7.12 → 1.7.13
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/package.json +1 -1
- package/smart-commit/cli.js +8 -6
package/package.json
CHANGED
package/smart-commit/cli.js
CHANGED
|
@@ -420,6 +420,7 @@ function buildPrompt(scopes, types, files, cwd, type) {
|
|
|
420
420
|
|
|
421
421
|
return `Plan git commits. Do not edit files or run git commit.
|
|
422
422
|
Return ONLY JSON: {"commits":[{"message":"type(scope): subject","files":["a.ts"]}]}
|
|
423
|
+
Every message must be type(scope): subject. Put a scope from the list in parentheses, including when the type is "other".
|
|
423
424
|
Types: ${types.join(', ')}
|
|
424
425
|
Scopes (exact): ${buildScopeEnum(scopes).join(', ')}
|
|
425
426
|
Subject rules:
|
|
@@ -1319,16 +1320,18 @@ async function validateAndNormalizePlans(cwd, plans, scopes, types) {
|
|
|
1319
1320
|
report.errors?.map((error) => error.message).join('; ') || 'invalid'
|
|
1320
1321
|
throw new Error(
|
|
1321
1322
|
`Commit message failed commitlint:\n ${plan.message}\n ${errors}\n` +
|
|
1322
|
-
'Use lower-case
|
|
1323
|
+
'Use type(scope): subject. Scope in parentheses is required. Subject is lower-case without camelCase (e.g. "public dir" not "publicDir").',
|
|
1323
1324
|
)
|
|
1324
1325
|
}
|
|
1325
1326
|
}
|
|
1326
1327
|
|
|
1327
1328
|
function repairCommitHeader(message, scopes, types) {
|
|
1328
|
-
const match = String(message || '')
|
|
1329
|
+
const match = String(message || '')
|
|
1330
|
+
.trim()
|
|
1331
|
+
.match(/^(\w+)(?:\(([^)]*)\))?:\s*(.+)$/)
|
|
1329
1332
|
if (!match) return message
|
|
1330
1333
|
|
|
1331
|
-
let [, type,
|
|
1334
|
+
let [, type, rawScope, subject] = match
|
|
1332
1335
|
const scopeEnum = buildScopeEnum(scopes)
|
|
1333
1336
|
if (types.length && !types.includes(type)) {
|
|
1334
1337
|
if (types.includes('chore')) type = 'chore'
|
|
@@ -1336,9 +1339,8 @@ function repairCommitHeader(message, scopes, types) {
|
|
|
1336
1339
|
else type = types[0]
|
|
1337
1340
|
}
|
|
1338
1341
|
|
|
1339
|
-
const matchedScope = matchScope(
|
|
1340
|
-
|
|
1341
|
-
else scope = pickScope(scopes, ['other'])
|
|
1342
|
+
const matchedScope = matchScope((rawScope || '').trim(), scopeEnum)
|
|
1343
|
+
const scope = matchedScope || pickScope(scopes, ['other'])
|
|
1342
1344
|
|
|
1343
1345
|
return normalizeCommitSubject(`${type}(${scope}): ${subject}`)
|
|
1344
1346
|
}
|