Make release posts generic

This commit is contained in:
Ryan Harg 2024-02-13 10:01:46 +01:00
parent fdcef5d209
commit e3cef3c004
3 changed files with 12 additions and 7 deletions

View file

@ -4,12 +4,17 @@ data class GithubRepo(private val repositoryPath: String) {
private val urlPrefix = "https://github.com/" private val urlPrefix = "https://github.com/"
val repoPath: String
val name: String val name: String
get() {
val usernameEnd = repoPath.indexOf("/") init {
return repoPath.substring(usernameEnd + 1).trimEnd { ch -> ch == '/' } repoPath = repoPath(repositoryPath)
}
val repoPath: String = repoPath(repositoryPath) val usernameEnd = repoPath.indexOf("/")
name = repoPath.substring(usernameEnd + 1).trimEnd { ch -> ch == '/' }
}
val capitalizedName = name.replaceFirstChar { it.uppercase() }
val url = urlPrefix + repoPath val url = urlPrefix + repoPath

View file

@ -10,7 +10,7 @@ data class Release(
) { ) {
val title: String get() = id val title: String get() = id
val text: String = val text: String =
"\uD83C\uDF89 Navidrome $title has been published!\n\nRelease notes are available here: $link\n\n#Navidrome" "\uD83C\uDF89 ${githubRepo.capitalizedName} $title has been published!\n\nRelease notes are available here: $link\n\n#${githubRepo.capitalizedName}"
} }
fun Release.asCollection() = listOf(this).asCollection() fun Release.asCollection() = listOf(this).asCollection()

View file

@ -109,7 +109,7 @@ class PublishersTest : DescribeSpec({
) )
} }
assertThat(statusSlot.captured).isEqualTo("\uD83C\uDF89 Navidrome v0.0.0 has been published!\n\nRelease notes are available here: https://example.com\n\n#Navidrome") assertThat(statusSlot.captured).isEqualTo("\uD83C\uDF89 Example v0.0.0 has been published!\n\nRelease notes are available here: https://example.com\n\n#Example")
} }
} }