@@ -19,6 +19,8 @@ function formatReferences(references: Reference[], baseUrl: string, github: stri
19
19
return ref . value
20
20
if ( ref . type === 'pull-request' || ref . type === 'issue' )
21
21
return `https://${ baseUrl } /${ github } /issues/${ ref . value . slice ( 1 ) } `
22
+
23
+ // 截取前面5个字符
22
24
return `[<samp>(${ ref . value . slice ( 0 , 5 ) } )</samp>](https://${ baseUrl } /${ github } /commit/${ ref . value } )`
23
25
} )
24
26
@@ -34,10 +36,15 @@ function formatLine(commit: Commit, options: ResolvedChangelogOptions) {
34
36
const hashRefs = formatReferences ( commit . references , options . baseUrl , options . repo as string , 'hash' )
35
37
36
38
let authors = join ( [ ...new Set ( commit . resolvedAuthors ?. map ( i => i . login ? `@${ i . login } ` : `**${ i . name } **` ) ) ] ) ?. trim ( )
39
+
37
40
if ( authors )
38
41
authors = `by ${ authors } `
39
42
40
- let refs = [ authors , prRefs , hashRefs ] . filter ( i => i ?. trim ( ) ) . join ( ' ' )
43
+ let refs = [
44
+ authors ,
45
+ prRefs ,
46
+ hashRefs ,
47
+ ] . filter ( i => i ?. trim ( ) ) . join ( ' ' )
41
48
42
49
if ( refs )
43
50
refs = ` - ${ refs } `
@@ -127,9 +134,9 @@ export async function generateMarkdown(commits: Commit[], options: ResolvedChang
127
134
lines . push ( '\n**No significant changes**' )
128
135
}
129
136
else {
130
- const url = `https://${ options . baseUrl } /${ options . repo } /compare/${ options . from } ...${ options . to } `
137
+ const url = `https://${ options . baseUrl } /${ options . repo } /compare/${ options . from } ...${ options . name } `
131
138
// 添加版本
132
- lines . push ( `\n**Release New Version v ${ options . to } [👉 View changes on GitHub](${ url } )**` )
139
+ lines . push ( `\n**Release New Version ${ options . name } [👉 View Changes On GitHub](${ url } )**` )
133
140
}
134
141
135
142
return convert ( lines . join ( '\n' ) . trim ( ) , true )
@@ -139,9 +146,9 @@ export async function generateMarkdown(commits: Commit[], options: ResolvedChang
139
146
* 更新changelog
140
147
* @param outputPath
141
148
* @param markdown
142
- * @param to
149
+ * @param releaseVersionName
143
150
*/
144
- export async function updateChangelog ( outputPath : string , markdown : string , to : string ) {
151
+ export async function updateChangelog ( outputPath : string , markdown : string , releaseVersionName : string ) {
145
152
let changelogMD : string
146
153
if ( existsSync ( outputPath ) ) {
147
154
console . info ( `Updating ${ outputPath } ` )
@@ -153,7 +160,7 @@ export async function updateChangelog(outputPath: string, markdown: string, to:
153
160
}
154
161
155
162
// 添加版本头部
156
- const newMd = `## ${ to } (${ dayjs ( ) . format ( 'YYYY-MM-DD' ) } )\n\n${ markdown } `
163
+ const newMd = `## ${ releaseVersionName } (${ dayjs ( ) . format ( 'YYYY-MM-DD' ) } )\n\n${ markdown } `
157
164
158
165
const lastEntry = changelogMD . match ( / ^ # # \s + (?: \S .* ) ? $ / m)
159
166
0 commit comments