Skip to content

Commit

Permalink
Copy release notes from previous release also when it's a staged rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
panpeter authored and SUPERCILEX committed Nov 2, 2023
1 parent df4eadf commit f3d3eef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ internal class DefaultTrackManager(
createDefaultTrack(config)
}

track.maybeCopyChangelogFromPreviousRelease(config.trackName)

publisher.updateTrack(editId, track)
}

Expand Down Expand Up @@ -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
}
}

Expand All @@ -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(
Expand Down

0 comments on commit f3d3eef

Please sign in to comment.