Skip to content
Snippets Groups Projects
Unverified Commit dd2d2311 authored by Ryan Laurie's avatar Ryan Laurie Committed by GitHub
Browse files

Milestone tracing logic update (#44956)

parent a73a1d38
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,8 @@ export function getLinkedIssues(body: string) {
}
export function getPRsFromCommitMessage(message: string) {
const result = [ ...message.matchAll(/\(#(\d+)\)/g) ];
const firstLine = message.split('\n\n')[0];
const result = [ ...firstLine.matchAll(/\(#(\d+)\)/g) ];
if (!result.length) {
console.log('no pr found in commit message', message);
return null;
......
......@@ -129,6 +129,14 @@ describe("getPRsFromCommitMessage", () => {
it("should return the PR id for a message with multiple backport PRs", () => {
expect(getPRsFromCommitMessage("Backport (#123) (#456)")).toEqual([123, 456]);
expect(getPRsFromCommitMessage("Backport (#1234) and (#4567)")).toEqual([1234, 4567]);
expect(getPRsFromCommitMessage("Backport (#1234) and (#4567) (#8989)")).toEqual([1234, 4567, 8989]);
});
it("should ignore pr numbers outside the title", () => {
expect(getPRsFromCommitMessage("Backport (#123) (#456)\n\n(#888) (#999)")).toEqual([123, 456]);
expect(getPRsFromCommitMessage("Backport (#1234) and (#4567)\n\n(#888)")).toEqual([1234, 4567]);
expect(getPRsFromCommitMessage("Backport (#1234)\n\n and (#4567) (#8989)")).toEqual([1234]);
expect(getPRsFromCommitMessage("Backport\n\n (#1234)\n\n and (#4567) (#8989)")).toEqual(null);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment