mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
Add function to close multiple issues with one keyword on commits (#2491)
This commit is contained in:
@@ -151,8 +151,13 @@ object StringUtil {
|
||||
* @return the iterator of issue id
|
||||
*/
|
||||
def extractCloseId(message: String): Seq[String] =
|
||||
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r
|
||||
.findAllIn(message)
|
||||
"#(\\d+)".r
|
||||
.findAllIn(
|
||||
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(,\\s?#(\\d+))*(?!\\w)".r
|
||||
.findAllIn(message)
|
||||
.toSeq
|
||||
.mkString(",")
|
||||
)
|
||||
.matchData
|
||||
.map(_.group(1))
|
||||
.toSeq
|
||||
|
||||
@@ -64,6 +64,9 @@ class StringUtilSpec extends AnyFunSpec {
|
||||
it("should returns Nil from message which does not contain close command") {
|
||||
assert(StringUtil.extractCloseId("(refs #123)").toSeq == Nil)
|
||||
}
|
||||
it("should extract 'close #x, #y, #z' and return extracted multi id") {
|
||||
assert(StringUtil.extractCloseId("(close #1, #2, #3, wip #4, close #5)").toSeq == Seq("1", "2", "3", "5"))
|
||||
}
|
||||
}
|
||||
|
||||
describe("getRepositoryViewerUrl") {
|
||||
|
||||
Reference in New Issue
Block a user