summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-07 11:03:47 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-07 11:03:47 +0100
commitaaf505dd0203d56e5d24977ffe440e780ada0b0e (patch)
treec2458c2c059974ee47cae5065d467032ad051fa2
parent252ccd1b62e9a571ed1d797a5d5c96205f62b371 (diff)
downloadSkyHanniChangelogBuilder-aaf505dd0203d56e5d24977ffe440e780ada0b0e.tar.gz
SkyHanniChangelogBuilder-aaf505dd0203d56e5d24977ffe440e780ada0b0e.tar.bz2
SkyHanniChangelogBuilder-aaf505dd0203d56e5d24977ffe440e780ada0b0e.zip
code cleanup
-rw-r--r--src/main/kotlin/Main.kt30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 1064ba3..830f28e 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -57,9 +57,7 @@ fun readPrs(prs: List<PullRequest>, firstPr: Int, hideWhenError: Boolean, title:
}
enum class OutputType {
- DISCORD_INTERNAL,
- GITHUB,
- DISCORD_PUBLIC,
+ DISCORD_INTERNAL, GITHUB, DISCORD_PUBLIC,
}
private fun print(
@@ -104,17 +102,15 @@ private fun print(
}
}
-fun getChangePrefix(name: String, outputType: OutputType): String {
- return when (outputType) {
- OutputType.DISCORD_INTERNAL -> "- "
- OutputType.GITHUB -> "+ "
- OutputType.DISCORD_PUBLIC -> when (name) {
- "New Features" -> "+ "
- "Improvements" -> "+ "
- "Fixes" -> "~ "
- "Removed Features" -> "- "
- else -> error("impossible change prefix")
- }
+fun getChangePrefix(name: String, outputType: OutputType): String = when (outputType) {
+ OutputType.DISCORD_INTERNAL -> "- "
+ OutputType.GITHUB -> "+ "
+ OutputType.DISCORD_PUBLIC -> when (name) {
+ "New Features" -> "+ "
+ "Improvements" -> "+ "
+ "Fixes" -> "~ "
+ "Removed Features" -> "- "
+ else -> error("impossible change prefix")
}
}
@@ -129,9 +125,11 @@ private fun findAllChanges(
var done = 0
// TODO find better solution for this sorting logic
- for (pr in prs.filter { it.closedAt != null }
+ val filtered = prs.filter { it.closedAt != null }
.map { it to Long.MAX_VALUE - Instant.parse(it.closedAt).toEpochMilli() }
- .sortedBy { it.second }.map { it.first }) {
+ .sortedBy { it.second }
+ .map { it.first }
+ for (pr in filtered) {
val number = pr.number
val prLink = pr.htmlUrl
val body = pr.body