Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,50 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
private companion object {

/**
* Formats github issues link.
* Formats GitHub issues link.
*
* Using the regex [LINK_REGEX], this function formats references to github issues or PRs into
* Using the regex [LINK_REGEX], this function formats references to GitHub issues or PRs into
* actual links.
*/
private fun githubIssueLinkFormatter(message: String): String =
LINK_REGEX.replace(message) {
private fun githubIssueLinkFormatter(message: String): String {
val prefix = getLinkPrefix(LINK_PREFIX_REGEX, message)
return LINK_REGEX.replace(message) {
val id = it.firstCapturedValue
"GitHub [#$id](//github.com/firebase/firebase-android-sdk/issues/$id){: .external}"
"${prefix}(GitHub [#$id](//github.com/firebase/firebase-android-sdk/issues/$id){: .external})"
}
}

/**
* Formats lists of GitHub issue links.
*
* Using the regex [LINK_REGEX], this function formats references to GitHub issues or PRs into
* actual links.
*/
private fun githubMultiIssueLinkFormatter(message: String): String {
val prefix = getLinkPrefix(MULTI_LINK_PREFIX_REGEX, message)
return MULTI_LINK_REGEX.replace(message) {
val result =
it.firstCapturedValue
.split(",")
.map { it.trim().removePrefix("#") }
.joinToString(",\n") { id ->
" GitHub [#$id](//github.com/firebase/firebase-android-sdk/issues/$id){: .external}"
}

"${prefix}(${result.trim()})"
}
}

/**
* Determines the prefix for a link based on its position in the text.
*
* If the link is preceded by non-blank content on the same line, it returns a newline with
* indentation to ensure the link appears on a new line.
*/
private fun getLinkPrefix(linkPrefixRegex: Regex, text: String): String {
val linkPrefixMatch = linkPrefixRegex.find(text) ?: return text
return if (linkPrefixMatch.firstCapturedValue.isNotBlank()) "\n " else ""
}

/**
* Formats product name references.
Expand All @@ -180,7 +214,7 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
* there are no more, used as the actual content.
*/
private val CONTENT_FORMATTERS: List<(String) -> String> =
listOf(::githubIssueLinkFormatter, ::productNameFormatter)
listOf(::githubIssueLinkFormatter, ::githubMultiIssueLinkFormatter, ::productNameFormatter)

/**
* Regex for GitHub issue links in change messages.
Expand Down Expand Up @@ -221,10 +255,46 @@ abstract class MakeReleaseNotesTask : DefaultTask() {
*/
private val LINK_REGEX =
Regex(
"(?:GitHub )?(?:\\[|\\()#(\\d+)(?:\\]|\\))(?:\\(.+?\\))?(?:\\{:\\s*\\.external\\})?",
"\\s*(?:GitHub )?(?:\\[|\\()#(\\d+)(?:\\]|\\))(?:\\(.+?\\))?(?:\\{:\\s*\\.external\\})?",
RegexOption.MULTILINE,
)

/**
* Regex used to identify the text preceding a single GitHub link on the same line. This helps
* determine if the link should be moved to a new line with indentation.
*/
private val LINK_PREFIX_REGEX = Regex("(^.*?)" + LINK_REGEX.pattern, RegexOption.MULTILINE)

/**
* Regex for multiple GitHub issue links in change messages.
*
* Matches a comma-separated list of issue numbers within brackets or parentheses. For example:
* `(#123, #456)` or `[#123, #456, #789]`
*
* Will find the following groups:
* ```kotlin
* [
* "#123, #456"
* ]
* ```
*
* But will *match* the following:
* ```kotlin
* "(#123, #456)"
* ```
*
* @see [Change.toReleaseNote]
*/
private val MULTI_LINK_REGEX =
Regex("\\s*(?:\\[|\\()(#\\d+(\\s*,\\s*#\\d+)+)(?:\\]|\\))", RegexOption.MULTILINE)

/**
* Regex used to identify the text preceding a list of GitHub links on the same line. This helps
* determine if the list should be moved to a new line with indentation.
*/
private val MULTI_LINK_PREFIX_REGEX =
Regex("(^.*?)" + MULTI_LINK_REGEX.pattern, RegexOption.MULTILINE)

/**
* Regex for product references in change messages.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ abstract class PomValidator : DefaultTask() {
"dagger", // dagger doesn't respect Semver
"listenablefuture", // guava's listenable future doesn't respect Semver
"auto-service-annotations", // auto-service-annotations doesn't respect SemVer
"re2j" // re2j doesn't respect SemVer
"re2j", // re2j doesn't respect SemVer
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Note: We did some super cool stuff here!

- [removed] Removed some old stuff from [firebase_storage_full] (#562)

- [changed] Added offline caching APIs. (#7814, #7833, #7848, #7875, #7885, #7887)

- [feature] Added this thing we wanted
[#444](//github.com/firebase/firebase-android-sdk/issues/number){:.external}

Expand Down
16 changes: 13 additions & 3 deletions plugins/src/test/resources/MakeReleaseNotes/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ Note: We did some super cool stuff here!

* {{feature}} {{storage}} now supports linking {{storage}} with {{storage}}

* {{fixed}} An issue on GitHub [#123](//github.com/firebase/firebase-android-sdk/issues/123){: .external}
* {{fixed}} An issue on
(GitHub [#123](//github.com/firebase/firebase-android-sdk/issues/123){: .external})

* {{removed}} Removed some old stuff from {{firebase_storage_full}} GitHub [#562](//github.com/firebase/firebase-android-sdk/issues/562){: .external}
* {{removed}} Removed some old stuff from {{firebase_storage_full}}
(GitHub [#562](//github.com/firebase/firebase-android-sdk/issues/562){: .external})

* {{changed}} Added offline caching APIs.
(GitHub [#7814](//github.com/firebase/firebase-android-sdk/issues/7814){: .external},
GitHub [#7833](//github.com/firebase/firebase-android-sdk/issues/7833){: .external},
GitHub [#7848](//github.com/firebase/firebase-android-sdk/issues/7848){: .external},
GitHub [#7875](//github.com/firebase/firebase-android-sdk/issues/7875){: .external},
GitHub [#7885](//github.com/firebase/firebase-android-sdk/issues/7885){: .external},
GitHub [#7887](//github.com/firebase/firebase-android-sdk/issues/7887){: .external})

* {{feature}} Added this thing we wanted
GitHub [#444](//github.com/firebase/firebase-android-sdk/issues/444){: .external}
(GitHub [#444](//github.com/firebase/firebase-android-sdk/issues/444){: .external})

* {{feature}} Added
[`Query.snapshots()`](/docs/reference/kotlin/com/google/firebase/firestore/ktx/package-summary#snapshots_1)
Expand Down
Loading