Add function to close multiple issues with one keyword on commits (#2491)

This commit is contained in:
onukura
2020-07-27 07:45:40 +09:00
committed by GitHub
parent 6224ec2a7b
commit 81c0e2037f
2 changed files with 10 additions and 2 deletions

View File

@@ -151,8 +151,13 @@ object StringUtil {
* @return the iterator of issue id * @return the iterator of issue id
*/ */
def extractCloseId(message: String): Seq[String] = def extractCloseId(message: String): Seq[String] =
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(?!\\w)".r "#(\\d+)".r
.findAllIn(
"(?i)(?<!\\w)(?:fix(?:e[sd])?|resolve[sd]?|close[sd]?)\\s+#(\\d+)(,\\s?#(\\d+))*(?!\\w)".r
.findAllIn(message) .findAllIn(message)
.toSeq
.mkString(",")
)
.matchData .matchData
.map(_.group(1)) .map(_.group(1))
.toSeq .toSeq

View File

@@ -64,6 +64,9 @@ class StringUtilSpec extends AnyFunSpec {
it("should returns Nil from message which does not contain close command") { it("should returns Nil from message which does not contain close command") {
assert(StringUtil.extractCloseId("(refs #123)").toSeq == Nil) 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") { describe("getRepositoryViewerUrl") {