From 5306a40503db3322f502f7bcdbe439b4cd6363d4 Mon Sep 17 00:00:00 2001 From: Ryan Harg Date: Tue, 2 Apr 2024 09:16:12 +0200 Subject: [PATCH] Fix hashtag --- .../de/rpr/githubreleases/model/GithubRepo.kt | 5 ++++- .../rpr/githubreleases/publishing/Publisher.kt | 2 +- .../rpr/githubreleases/model/GithubRepoTest.kt | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/src/test/kotlin/de/rpr/githubreleases/model/GithubRepoTest.kt diff --git a/app/src/main/kotlin/de/rpr/githubreleases/model/GithubRepo.kt b/app/src/main/kotlin/de/rpr/githubreleases/model/GithubRepo.kt index 507fe8c..9726c3d 100644 --- a/app/src/main/kotlin/de/rpr/githubreleases/model/GithubRepo.kt +++ b/app/src/main/kotlin/de/rpr/githubreleases/model/GithubRepo.kt @@ -16,7 +16,10 @@ data class GithubRepo( name = repoPath.substring(usernameEnd + 1).trimEnd { ch -> ch == '/' } } - @Transient val capitalizedName = name.replaceFirstChar { it.uppercase() } + @Transient val capitalizedName = + name + .split("-", "_", ".", ";", "+") + .joinToString("") { part -> part.replaceFirstChar { it.uppercase() } } val url = urlPrefix + repoPath diff --git a/app/src/main/kotlin/de/rpr/githubreleases/publishing/Publisher.kt b/app/src/main/kotlin/de/rpr/githubreleases/publishing/Publisher.kt index 6611128..1f313e4 100644 --- a/app/src/main/kotlin/de/rpr/githubreleases/publishing/Publisher.kt +++ b/app/src/main/kotlin/de/rpr/githubreleases/publishing/Publisher.kt @@ -29,7 +29,7 @@ class Publisher( if (!dryRun) { request.execute() } else { - log("Dry-Run, skipping publishing of events...") + log("Dry-Run, skipping publishing of event...") } return@mapNotNull release } catch (ex: BigBoneRequestException) { diff --git a/app/src/test/kotlin/de/rpr/githubreleases/model/GithubRepoTest.kt b/app/src/test/kotlin/de/rpr/githubreleases/model/GithubRepoTest.kt new file mode 100644 index 0000000..81998d8 --- /dev/null +++ b/app/src/test/kotlin/de/rpr/githubreleases/model/GithubRepoTest.kt @@ -0,0 +1,18 @@ +package de.rpr.githubreleases.model + +import assertk.assertThat +import assertk.assertions.isEqualTo +import io.kotest.core.spec.style.DescribeSpec + +class GithubRepoTest : DescribeSpec({ + + describe("GithubRepo") { + + it("capitalizedName should be correct") { + assertThat(GithubRepo("test/test-one").capitalizedName).isEqualTo("TestOne") + assertThat(GithubRepo("test/test.one").capitalizedName).isEqualTo("TestOne") + assertThat(GithubRepo("test/test+one").capitalizedName).isEqualTo("TestOne") + assertThat(GithubRepo("test/test;one").capitalizedName).isEqualTo("TestOne") + } + } +})