Skip to content

Commit

Permalink
Merge branch 'fix-changelog-hypens-droid-1352'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Sep 20, 2024
2 parents c71fd5a + d88431c commit c268dda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import net.mullvad.mullvadvpn.util.trimAll

private const val MISSING_VERSION_CODE = -1
private const val NEWLINE_CHAR = '\n'
private const val SPACE_STRING = " "
private const val BULLET_POINT_CHAR = '-'
private const val LAST_SHOWED_CHANGELOG_VERSION_CODE = "last_showed_changelog_version_code"

Expand All @@ -22,9 +21,9 @@ class ChangelogRepository(
preferences.edit().putInt(LAST_SHOWED_CHANGELOG_VERSION_CODE, versionCode).apply()

fun getLastVersionChanges(): List<String> =
dataProvider
.getChangelog()
.split(BULLET_POINT_CHAR)
.map { it.split(NEWLINE_CHAR).trimAll().joinToString(SPACE_STRING).trim() }
// Prepend with a new line char so each entry consists of NEWLINE_CHAR + BULLET_POINT_CHAR
(NEWLINE_CHAR + dataProvider.getChangelog())
.split(NEWLINE_CHAR.toString() + BULLET_POINT_CHAR)
.trimAll()
.filter { it.isNotEmpty() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class ChangelogRepositoryTest {
fun `when given a changelog text should return a list of correctly formatted strings`() {
// Arrange
val testChangelog =
"- Added very nice new feature with a very long descriptive message\n" +
" about how it works...\n" +
"- Added very nice new feature with a very long descriptive message-with-hyphens\n" +
" - about how it works...\n" +
"- Fixed super bad leak."
val expectedResult =
listOf(
"Added very nice new feature with a very long descriptive message about how it works...",
"Added very nice new feature with a very long descriptive message-with-hyphens\n - about how it works...",
"Fixed super bad leak.",
)
every { mockDataProvider.getChangelog() } returns testChangelog
Expand Down

0 comments on commit c268dda

Please sign in to comment.