Get GitHub Commit Messages Since Tag

Open get-commits in Script Kit

// Name: Get GitHub Commits Messages Since Tag
// Description: Get all commit messages since a tag
// Author: John Lindquist
// Twitter: @johnlindquist
import "@johnlindquist/kit"
let { Octokit } = await import("@octokit/rest")
let ownerRepo = await arg("Enter username/repo. Example: johnlindquist/kit")
let [owner, repo] = ownerRepo.split("/")
let tag = await arg("Tag. Example: v1.54.53")
let client = new Octokit({
auth: await env("GITHUB_PERSONAL_ACCESS_TOKEN"),
})
let page = 1
let hasMorePages = true
let messages = []
let ref = null
let tagPage = 1
while (!ref) {
let listTags = await client.repos.listTags({
owner,
repo,
per_page: 100,
name: tag,
page: tagPage,
})
tagPage++
ref = listTags.data.find(t => t.name === tag).commit.sha
}
let commit = await client.repos.getCommit({
owner,
repo,
ref,
})
let since = commit.data.commit.author.date
while (hasMorePages) {
let data = await client.repos.listCommits({
owner,
repo,
since,
per_page: 100,
page: page,
})
hasMorePages = data.data.length === 100
messages = messages.concat(data.data.map(c => c.commit.message))
page++
}
let text = messages.join("\n\n")
if (env?.["GITHUB_SCRIPTKIT_TOKEN"]) {
let response = await createGist(text, {
description: `Commit messages since ${tag}`,
isPublic: false,
fileName: "commit-messages.txt",
})
open(response.html_url)
debugger
} else {
await editor(text)
}