From 935acb735f90e514b9a0cf1e1916310b7a95947c Mon Sep 17 00:00:00 2001 From: Piotr Wilczek Date: Wed, 1 Nov 2023 11:18:07 +0300 Subject: [PATCH] Copy release notes from previous release also when it's a staged rollout --- README.md | 2 ++ .../androidpublisher/internal/TrackManager.kt | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0285dac79..7bb12834e 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,8 @@ src/main/play/release-notes/en-US/default.txt When you publish to the beta channel, the `beta.txt` release notes will be uploaded. For any other channel, `default.txt` will be uploaded. +If no release notes are found, GPP will try to copy release notes from the previous release. + > Note: the Play Store limits your release notes to a maximum of 500 characters. #### Uploading developer facing release names diff --git a/play/android-publisher/src/main/kotlin/com/github/triplet/gradle/androidpublisher/internal/TrackManager.kt b/play/android-publisher/src/main/kotlin/com/github/triplet/gradle/androidpublisher/internal/TrackManager.kt index 3d92aacdf..2e1475425 100644 --- a/play/android-publisher/src/main/kotlin/com/github/triplet/gradle/androidpublisher/internal/TrackManager.kt +++ b/play/android-publisher/src/main/kotlin/com/github/triplet/gradle/androidpublisher/internal/TrackManager.kt @@ -71,8 +71,6 @@ internal class DefaultTrackManager( createDefaultTrack(config) } - track.maybeCopyChangelogFromPreviousRelease(config.trackName) - publisher.updateTrack(editId, track) } @@ -118,8 +116,10 @@ internal class DefaultTrackManager( } } } else { - track.releases = track.releases + - listOf(TrackRelease().mergeChanges(config.versionCodes, config.base)) + val release = TrackRelease().mergeChanges(config.versionCodes, config.base).apply { + maybeCopyChangelogFromPreviousRelease(config.trackName) + } + track.releases = track.releases + release } } @@ -130,24 +130,29 @@ internal class DefaultTrackManager( val track = publisher.getTrack(editId, config.trackName) val keep = track.releases.orEmpty().filterNot { it.isRollout() } - track.releases = keep + listOf(TrackRelease().mergeChanges(config.versionCodes, config.base)) + val release = TrackRelease().mergeChanges(config.versionCodes, config.base).apply { + maybeCopyChangelogFromPreviousRelease(config.trackName) + } + track.releases = keep + release return track } private fun createDefaultTrack(config: TrackManager.UpdateConfig) = Track().apply { track = config.trackName - releases = listOf(TrackRelease().mergeChanges(config.versionCodes, config.base)) + val release = TrackRelease().mergeChanges(config.versionCodes, config.base).apply { + maybeCopyChangelogFromPreviousRelease(config.trackName) + } + releases = listOf(release) } - private fun Track.maybeCopyChangelogFromPreviousRelease(trackName: String) { - val release = releases.singleOrNull { track == trackName } ?: return - if (!release.releaseNotes.isNullOrEmpty()) return + private fun TrackRelease.maybeCopyChangelogFromPreviousRelease(trackName: String) { + if (!releaseNotes.isNullOrEmpty()) return val previousRelease = publisher.getTrack(editId, trackName) .releases.orEmpty() .maxByOrNull { it.versionCodes.orEmpty().maxOrNull() ?: 1 } - release.releaseNotes = previousRelease?.releaseNotes + releaseNotes = previousRelease?.releaseNotes } private fun TrackRelease.mergeChanges(