refactor checksum regex in GH release notes (#858)

This commit is contained in:
Cuong-Tran 2025-04-19 22:43:07 +07:00
parent fd26108b93
commit 98f93bfbad
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
5 changed files with 10 additions and 6 deletions

View file

@ -853,6 +853,7 @@ private fun MangaSummary(
modifier = modifier.clipToBounds(),
contents = listOf(
{
// shrunk: calculate minimum size when shrunk
Text(
// Shows at least 3 lines if no notes
// when there are notes show 6
@ -861,6 +862,7 @@ private fun MangaSummary(
)
},
{
// expanded: calculate maximum size when expanded
Column {
MangaNotesSection(
content = notes,
@ -875,6 +877,7 @@ private fun MangaSummary(
}
},
{
// actual: the actual displayed content
Column {
MangaNotesSection(
content = notes,
@ -891,6 +894,7 @@ private fun MangaSummary(
}
},
{
// scrim
val colors = listOf(Color.Transparent, MaterialTheme.colorScheme.background)
Box(
modifier = Modifier.background(Brush.verticalGradient(colors = colors)),

View file

@ -22,7 +22,7 @@ class NewUpdateScreen(
val navigator = LocalNavigator.currentOrThrow
val context = LocalContext.current
val changelogInfoNoChecksum = remember {
changelogInfo.replace("""---(\R|.)*Checksums(\R|.)*""".toRegex(), "")
changelogInfo
}
NewUpdateScreen(

View file

@ -21,7 +21,7 @@ class WhatsNewScreen(
val context = LocalContext.current
val navigator = LocalNavigator.currentOrThrow
val changelogInfoNoChecksum = remember {
changelogInfo.replace("""---(\R|.)*Checksums(\R|.)*""".toRegex(), "")
changelogInfo
}
WhatsNewScreen(

View file

@ -50,6 +50,7 @@ class ReleaseServiceImpl(
info = release.info.replace(gitHubUsernameMentionRegex) { mention ->
"[${mention.value}](https://github.com/${mention.value.substring(1)})"
}
.replace(checksumRegex, "")
// KMK -->
.replace(getHubDownloadBadgeRegex, "")
.replace(gitHubCommitsCompareRegex) { matchResult ->
@ -57,7 +58,6 @@ class ReleaseServiceImpl(
val repo = matchResult.groups["repo"]!!.value
val from = matchResult.groups["from"]!!.value
val to = matchResult.groups["to"]!!.value
"[$owner/$repo@$from...$to](https://github.com/$owner/$repo/compare/$from...$to)"
},
// KMK <--
@ -104,6 +104,8 @@ class ReleaseServiceImpl(
private val gitHubUsernameMentionRegex = """\B@([a-z0-9](?:-(?=[a-z0-9])|[a-z0-9]){0,38}(?<=[a-z0-9]))"""
.toRegex(RegexOption.IGNORE_CASE)
private val checksumRegex = """---(\R|.)*Checksums(\R|.)*""".toRegex()
// KMK -->
private val getHubDownloadBadgeRegex = """\[!\[GitHub downloads]\(.*\)]\(.*\)"""
.toRegex(RegexOption.IGNORE_CASE)

View file

@ -59,13 +59,11 @@ class GetApplicationRelease(
suspend fun awaitReleaseNotes(arguments: Arguments): Result {
val releases = service.releaseNotes(arguments)
.filter { !it.preRelease }
val checksumRegex = """---(\R|.)*Checksums(\R|.)*""".toRegex()
val release = releases.firstOrNull()
?.copy(
info = releases.joinToString("\r---\r") {
"## ${it.version}\r\r" +
it.info.replace(checksumRegex, "")
"## ${it.version}\r\r${it.info}"
},
)
if (release == null) return Result.NoNewUpdate