refactor checksum regex in GH release notes (#858)
This commit is contained in:
parent
fd26108b93
commit
98f93bfbad
5 changed files with 10 additions and 6 deletions
|
|
@ -853,6 +853,7 @@ private fun MangaSummary(
|
||||||
modifier = modifier.clipToBounds(),
|
modifier = modifier.clipToBounds(),
|
||||||
contents = listOf(
|
contents = listOf(
|
||||||
{
|
{
|
||||||
|
// shrunk: calculate minimum size when shrunk
|
||||||
Text(
|
Text(
|
||||||
// Shows at least 3 lines if no notes
|
// Shows at least 3 lines if no notes
|
||||||
// when there are notes show 6
|
// when there are notes show 6
|
||||||
|
|
@ -861,6 +862,7 @@ private fun MangaSummary(
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// expanded: calculate maximum size when expanded
|
||||||
Column {
|
Column {
|
||||||
MangaNotesSection(
|
MangaNotesSection(
|
||||||
content = notes,
|
content = notes,
|
||||||
|
|
@ -875,6 +877,7 @@ private fun MangaSummary(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// actual: the actual displayed content
|
||||||
Column {
|
Column {
|
||||||
MangaNotesSection(
|
MangaNotesSection(
|
||||||
content = notes,
|
content = notes,
|
||||||
|
|
@ -891,6 +894,7 @@ private fun MangaSummary(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// scrim
|
||||||
val colors = listOf(Color.Transparent, MaterialTheme.colorScheme.background)
|
val colors = listOf(Color.Transparent, MaterialTheme.colorScheme.background)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.background(Brush.verticalGradient(colors = colors)),
|
modifier = Modifier.background(Brush.verticalGradient(colors = colors)),
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class NewUpdateScreen(
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val changelogInfoNoChecksum = remember {
|
val changelogInfoNoChecksum = remember {
|
||||||
changelogInfo.replace("""---(\R|.)*Checksums(\R|.)*""".toRegex(), "")
|
changelogInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
NewUpdateScreen(
|
NewUpdateScreen(
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class WhatsNewScreen(
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val changelogInfoNoChecksum = remember {
|
val changelogInfoNoChecksum = remember {
|
||||||
changelogInfo.replace("""---(\R|.)*Checksums(\R|.)*""".toRegex(), "")
|
changelogInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
WhatsNewScreen(
|
WhatsNewScreen(
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ class ReleaseServiceImpl(
|
||||||
info = release.info.replace(gitHubUsernameMentionRegex) { mention ->
|
info = release.info.replace(gitHubUsernameMentionRegex) { mention ->
|
||||||
"[${mention.value}](https://github.com/${mention.value.substring(1)})"
|
"[${mention.value}](https://github.com/${mention.value.substring(1)})"
|
||||||
}
|
}
|
||||||
|
.replace(checksumRegex, "")
|
||||||
// KMK -->
|
// KMK -->
|
||||||
.replace(getHubDownloadBadgeRegex, "")
|
.replace(getHubDownloadBadgeRegex, "")
|
||||||
.replace(gitHubCommitsCompareRegex) { matchResult ->
|
.replace(gitHubCommitsCompareRegex) { matchResult ->
|
||||||
|
|
@ -57,7 +58,6 @@ class ReleaseServiceImpl(
|
||||||
val repo = matchResult.groups["repo"]!!.value
|
val repo = matchResult.groups["repo"]!!.value
|
||||||
val from = matchResult.groups["from"]!!.value
|
val from = matchResult.groups["from"]!!.value
|
||||||
val to = matchResult.groups["to"]!!.value
|
val to = matchResult.groups["to"]!!.value
|
||||||
|
|
||||||
"[$owner/$repo@$from...$to](https://github.com/$owner/$repo/compare/$from...$to)"
|
"[$owner/$repo@$from...$to](https://github.com/$owner/$repo/compare/$from...$to)"
|
||||||
},
|
},
|
||||||
// KMK <--
|
// 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]))"""
|
private val gitHubUsernameMentionRegex = """\B@([a-z0-9](?:-(?=[a-z0-9])|[a-z0-9]){0,38}(?<=[a-z0-9]))"""
|
||||||
.toRegex(RegexOption.IGNORE_CASE)
|
.toRegex(RegexOption.IGNORE_CASE)
|
||||||
|
|
||||||
|
private val checksumRegex = """---(\R|.)*Checksums(\R|.)*""".toRegex()
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
private val getHubDownloadBadgeRegex = """\[!\[GitHub downloads]\(.*\)]\(.*\)"""
|
private val getHubDownloadBadgeRegex = """\[!\[GitHub downloads]\(.*\)]\(.*\)"""
|
||||||
.toRegex(RegexOption.IGNORE_CASE)
|
.toRegex(RegexOption.IGNORE_CASE)
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,11 @@ class GetApplicationRelease(
|
||||||
suspend fun awaitReleaseNotes(arguments: Arguments): Result {
|
suspend fun awaitReleaseNotes(arguments: Arguments): Result {
|
||||||
val releases = service.releaseNotes(arguments)
|
val releases = service.releaseNotes(arguments)
|
||||||
.filter { !it.preRelease }
|
.filter { !it.preRelease }
|
||||||
val checksumRegex = """---(\R|.)*Checksums(\R|.)*""".toRegex()
|
|
||||||
|
|
||||||
val release = releases.firstOrNull()
|
val release = releases.firstOrNull()
|
||||||
?.copy(
|
?.copy(
|
||||||
info = releases.joinToString("\r---\r") {
|
info = releases.joinToString("\r---\r") {
|
||||||
"## ${it.version}\r\r" +
|
"## ${it.version}\r\r${it.info}"
|
||||||
it.info.replace(checksumRegex, "")
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (release == null) return Result.NoNewUpdate
|
if (release == null) return Result.NoNewUpdate
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue