Skip to content

Commit 85bb4a8

Browse files
committed
build: Enhance changelog generation with custom tag support
1 parent df064ed commit 85bb4a8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/changelog.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ async function getCommitsSince(commitId) {
2424
}
2525
}
2626

27-
// 获取从最近的标签开始的所有最新记录
28-
async function getCommitsSinceLatestTag() {
27+
// 从指定标签获取所有最新记录
28+
async function getCommitsSinceTag(tagId) {
2929
const tags = promisify(git.tags.bind(git))
3030
const log = promisify(git.log.bind(git))
31-
const latestTag = (await tags()).latest
3231

33-
if (!latestTag) {
32+
if (!tagId) {
33+
tagId = (await tags()).latest
34+
}
35+
36+
if (!tagId) {
3437
console.error('No tags found.')
3538
return []
3639
}
3740

3841
const logOptions = {
39-
from: latestTag,
42+
from: tagId,
4043
}
4144

4245
try {
@@ -81,7 +84,8 @@ async function generateLogs(name, logs) {
8184
try {
8285
// const commits = await getCommitsSince('d9acb96')
8386
const commitId = args.commit || args.C
84-
const getCommitLogs = () => (commitId ? getCommitsSince(commitId) : getCommitsSinceLatestTag())
87+
const getCommitLogs = () =>
88+
commitId ? getCommitsSince(commitId) : getCommitsSinceTag(args.tag)
8589
const commits = await getCommitLogs()
8690
const formattedCommits = formatCommits(commits, (commit) => {
8791
return moduleRegex.test(commit.message)

0 commit comments

Comments
 (0)