From 74a9c654c1602e424c6eecff19f3844f0dd58937 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Mon, 15 Apr 2024 14:23:18 +0200 Subject: [PATCH] Exclude cherry-picks --- tools/changelog.main.kts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/changelog.main.kts b/tools/changelog.main.kts index 573bd41962..74beef95d0 100644 --- a/tools/changelog.main.kts +++ b/tools/changelog.main.kts @@ -33,6 +33,11 @@ val firstCommit = args.getOrNull(0) ?: error("Please call this way: kotlin chang val lastCommit = args.getOrNull(1) ?: error("Please call this way: kotlin changelog.main.kts ") val token = args.getOrNull(2) +// TODO automate or pass as arguments +// Exclude cherry-picked commits to the previous versions +val excludeFirstCommit = "v1.6.0-rc01" +val excludeLastCommit = "v1.6.2" + if (token == null) { println("To increase the rate limit, specify token (https://github.com/settings/tokens): kotlin changelog.main.kts TOKEN") } @@ -137,9 +142,18 @@ fun entriesForRepo(repo: String): List { val commits = fetchPagedUntilEmpty { page -> request("https://api.github.com/repos/$repo/compare/$firstCommit...$lastCommit?per_page=1000&page=$page") .commits - } + }.toSet() + + val excludedCommitMessages = fetchPagedUntilEmpty { page -> + request("https://api.github.com/repos/$repo/compare/$excludeFirstCommit...$excludeLastCommit?per_page=1000&page=$page") + .commits + .map { it.commit.message } + }.toSet() + + // Exclude cherry-picks with the same message (they have a different SHA, we can compare by it) + val nonCherrypickedCommits = commits.filter { it.commit.message !in excludedCommitMessages } - return commits + return nonCherrypickedCommits .map { changelogEntryFor(it, prForCommit(it)) } }