Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95b8af3

Browse files
authored
fix: fix parsing a breaking change commit with scope (#61)
1 parentbb02365 commit95b8af3

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

‎src/print-commits.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,21 @@ export function parseCommits(raw: string) {
3636
.map((line):ParsedCommit=>{
3737
const[hash, ...parts]=line.split(' ')
3838
constmessage=parts.join(' ')
39-
constmatch=message.match(/^(\w+)(!)?(\([^)]+\))?:(.*)$/)
39+
constmatch=message.match(/^(\w+)(!)?(\([^)]+\))?(!)?:(.*)$/)
4040
if(match){
4141
letcolor=messageColorMap[match[1].toLowerCase()]||((c:string)=>c)
42-
if(match[2]==='!'){
42+
constbreaking=match[2]==='!'||match[4]==='!'
43+
if(breaking){
4344
color=s=>c.inverse(c.red(s))
4445
}
45-
consttag=[match[1],match[2]].filter(Boolean).join('')
46+
consttag=[match[1],match[2],match[4]].filter(Boolean).join('')
4647
constscope=match[3]||''
4748
return{
4849
hash,
4950
tag,
50-
message:match[4].trim(),
51+
message:match[5].trim(),
5152
scope,
52-
breaking:match[2]==='!',
53+
breaking,
5354
color,
5455
}
5556
}

‎test/parse-commits.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ bfad9f238 fix!(extractor-arbitrary-variants): skip extracting encoded html entit
1919
35297359b docs(rules): explain symbols.layer in symbols docs (#4145)
2020
9be7b299d feat(core): add symbols.layer (#4143)
2121
bd4d8e998 docs(config): layers using variants (#4144)
22+
67f3237dc refactor!: make arbitrary variants extractor callable (#4239)
23+
5420b1316 feat(core)!: deprecate \`new UnoGenerator\`, make \`createGenerator()\` async (#4268)
2224
`
2325

2426
it('parseCommits',async()=>{
@@ -27,6 +29,22 @@ it('parseCommits', async () => {
2729
expect(parsed)
2830
.toMatchInlineSnapshot(`
2931
[
32+
{
33+
"breaking": true,
34+
"color": [Function],
35+
"hash": "5420b1316",
36+
"message": "deprecate \`new UnoGenerator\`, make \`createGenerator()\` async (#4268)",
37+
"scope": "(core)",
38+
"tag": "feat!",
39+
},
40+
{
41+
"breaking": true,
42+
"color": [Function],
43+
"hash": "67f3237dc",
44+
"message": "make arbitrary variants extractor callable (#4239)",
45+
"scope": "",
46+
"tag": "refactor!",
47+
},
3048
{
3149
"breaking": false,
3250
"color": [Function],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp