Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
452382bc
Unverified
Commit
452382bc
authored
8 months ago
by
Ryan Laurie
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix infinite backport PR recursion in milestone setter (#44593)
* fix infinite backport PR recursion * dedupe issue numbers
parent
ea69066d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
release/src/linked-issues.ts
+6
-0
6 additions, 0 deletions
release/src/linked-issues.ts
release/src/linked-issues.unit.spec.ts
+16
-1
16 additions, 1 deletion
release/src/linked-issues.unit.spec.ts
release/src/milestones.ts
+16
-10
16 additions, 10 deletions
release/src/milestones.ts
with
38 additions
and
11 deletions
release/src/linked-issues.ts
+
6
−
0
View file @
452382bc
...
...
@@ -22,3 +22,9 @@ export function getPRsFromCommitMessage(message: string) {
return
result
.
map
(
r
=>
Number
(
r
[
1
]));
}
// backport PRs just have a pr number in the body without a keyword
export
function
getBackportSourcePRNumber
(
body
:
string
)
{
const
matches
=
body
.
match
(
/#
(\d
+
)
/
);
return
matches
?
Number
(
matches
[
1
])
:
null
;
}
This diff is collapsed.
Click to expand it.
release/src/linked-issues.unit.spec.ts
+
16
−
1
View file @
452382bc
import
{
getLinkedIssues
,
getPRsFromCommitMessage
}
from
"
./linked-issues
"
;
import
{
getLinkedIssues
,
getPRsFromCommitMessage
,
getBackportSourcePRNumber
}
from
"
./linked-issues
"
;
const
closingKeywords
=
[
"
Close
"
,
...
...
@@ -131,3 +131,18 @@ describe("getPRsFromCommitMessage", () => {
expect
(
getPRsFromCommitMessage
(
"
Backport (#1234) and (#4567)
"
)).
toEqual
([
1234
,
4567
]);
});
});
describe
(
"
getBackportSourcePRNumber
"
,
()
=>
{
it
(
"
should return `null` when no PR is found
"
,
()
=>
{
expect
(
getBackportSourcePRNumber
(
""
)).
toBeNull
();
expect
(
getBackportSourcePRNumber
(
"
Lorem ipsum dolor sit amet.
"
)).
toBeNull
();
expect
(
getBackportSourcePRNumber
(
"
#yolo
"
)).
toBeNull
();
});
it
(
"
should return the pr number when it is found
"
,
()
=>
{
expect
(
getBackportSourcePRNumber
(
"
#4567
"
)).
toBe
(
4567
);
expect
(
getBackportSourcePRNumber
(
"
#4567
"
)).
toBe
(
4567
);
expect
(
getBackportSourcePRNumber
(
"
backports #4567 and #6789
"
)).
toBe
(
4567
);
});
});
This diff is collapsed.
Click to expand it.
release/src/milestones.ts
+
16
−
10
View file @
452382bc
import
_
from
"
underscore
"
;
import
{
getMilestones
}
from
"
./github
"
;
import
{
getLinkedIssues
,
getPRsFromCommitMessage
}
from
"
./linked-issues
"
;
import
{
getLinkedIssues
,
getPRsFromCommitMessage
,
getBackportSourcePRNumber
}
from
"
./linked-issues
"
;
import
type
{
Issue
,
GithubProps
,
Milestone
}
from
"
./types
"
;
import
{
getMajorVersion
,
...
...
@@ -54,13 +54,17 @@ async function getOriginalPR({
pull_number
:
pullRequestNumber
,
});
if
(
pull
?.
data
&&
isBackport
(
pull
.
data
))
{
return
getOriginalPR
({
github
,
repo
,
owner
,
pullRequestNumber
:
pull
.
data
.
number
});
if
(
pull
?.
data
&&
isBackport
(
pull
.
data
)
&&
pull
.
data
.
body
)
{
const
sourcePRNumber
=
getBackportSourcePRNumber
(
pull
.
data
.
body
);
if
(
sourcePRNumber
&&
sourcePRNumber
!==
pullRequestNumber
)
{
console
.
log
(
'
found backport PR
'
,
pull
.
data
.
number
,
'
source PR
'
,
sourcePRNumber
);
return
getOriginalPR
({
github
,
repo
,
owner
,
pullRequestNumber
:
sourcePRNumber
,
});
}
}
const
linkedIssues
=
await
getLinkedIssues
(
pull
.
data
.
body
??
''
);
...
...
@@ -182,9 +186,11 @@ export async function setMilestoneForCommits({
})));
}
console
.
log
(
`Tagging
${
issuesToTag
.
length
}
issues with milestone
${
nextMilestone
.
title
}
`
)
const
uniqueIssuesToTag
=
_
.
uniq
(
issuesToTag
);
console
.
log
(
`Tagging
${
uniqueIssuesToTag
.
length
}
issues with milestone
${
nextMilestone
.
title
}
`
)
for
(
const
issueNumber
of
i
ssuesToTag
)
{
// for loop to avoid rate limiting
for
(
const
issueNumber
of
uniqueI
ssuesToTag
)
{
// for loop to avoid rate limiting
await
setMilestone
({
github
,
owner
,
repo
,
issueNumber
,
milestone
:
nextMilestone
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment