From 6be28258a5f1c1035fdaf01fa13f492e80e10b4a Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 21 Feb 2023 10:18:07 +0800 Subject: [PATCH] ci: fix dangerjs check for github link --- .gitlab/dangerfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab/dangerfile.js b/.gitlab/dangerfile.js index d9d58ed379..9dafd00a82 100644 --- a/.gitlab/dangerfile.js +++ b/.gitlab/dangerfile.js @@ -64,12 +64,13 @@ function checkMrJiraLinks() { const matchBlockRelated = mrDescription.match(/\#\# Related.*$/s); // Match MR description starting with line ## Related till the end of MR description const testJiraLabels = /[A-Z]+-[0-9]+/.test(matchBlockRelated ? matchBlockRelated[0] : ''); // Test if pattern of Jira label "JIRA-1234" or "RDT-311" is in section Related const ghIssueTicket = /IDFGH-[0-9]+/.test(matchBlockRelated ? matchBlockRelated[0] : ''); // Check if there is JIRA link starts with "IDFGH-*" in MR description, section "Related" + const testGithubLink = /Closes https:\/\/github\.com\/espressif\/esp-idf\/issues\/[0-9]+/ if (!mrDescription.toUpperCase().includes("## RELATED") || !testJiraLabels) { // Missing section "Related" or missing links to JIRA tickets return warn("Please add links to JIRA issues to the MR description section `Related`."); } else if (ghIssueTicket) { // Found JIRA ticket linked GitHub issue - if (!mrCommitMessages.includes(/Closes https:\/\/github\.com\/espressif\/esp-idf\/issues\/[0-9]+/)) { // Commit message does not contain a link to close the issue on GitHub + if (!testGithubLink.test(mrCommitMessages)) { // Commit message does not contain a link to close the issue on GitHub return warn("Please add GitHub issue closing link `Closes https://github.com/espressif/esp-idf/issues/` to the commit message."); } }