Skip to content

Commit

Permalink
fix release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
d1y committed Jun 20, 2024
1 parent e250458 commit e985406
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
20 changes: 17 additions & 3 deletions script/draft-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ function parseCommitBody(body) {
return result
}

/**
* @param {string} a
* @param {string} b
* @returns
*/
function getTwoTagCommitHashs(a, b) {
return execSync(`git log --oneline --format="%h" ${a}...${b}`).toString('utf-8').trim().split("\n")
}
Expand All @@ -37,6 +42,9 @@ function getLatestTags(size = 2) {
return execSync(`git tag -l --sort=-v:refname | head -${size}`).toString('utf-8').trim().split("\n")
}

/**
* @param {string} tag
*/
function getTagNote(tag) {
const _ = execSync(`git show ${tag} --stat=0 --no-patch --format="%N"`).toString('utf-8').trim()
const note = _.split("\n").filter(item=> { return !!item.trim() })
Expand All @@ -47,8 +55,14 @@ function getTagNote(tag) {
}

;(async()=> {
const tags = getLatestTags()
const hashs = getTwoTagCommitHashs(tags[0], tags[1])
const repo = "waifu-project/movie"
const resp = await fetch(`https://api.github.com/repos/${repo}/tags`)
/** @type {GithubTagResponse} */
const tags = await resp.json()
const now = tags[0].name
const old = tags[1].name//我赌你枪里没有子弹
// const tags = getLatestTags()
const hashs = getTwoTagCommitHashs(now, old)
let notes = []
for (const hash of hashs) {
const body = getCommitBody(hash)
Expand All @@ -57,7 +71,7 @@ function getTagNote(tag) {
notes = [...notes, ..._]
}
}
let releaseNote = getTagNote(tags[0])
let releaseNote = getTagNote(now)
releaseNote += notes.join("\n")
console.log(releaseNote)
})()
5 changes: 5 additions & 0 deletions script/tag.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface Tag {
name: string
}

type GithubTagResponse = Array<Tag>

0 comments on commit e985406

Please sign in to comment.