Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
7c410c12
Commit
7c410c12
authored
7 years ago
by
Rhys Arkins
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: ignore mistakenly closed PRs and recreated closed (#951)
parent
ee44d1c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/branch/check-existing.js
+25
-0
25 additions, 0 deletions
lib/workers/branch/check-existing.js
test/workers/branch/check-existing.spec.js
+8
-1
8 additions, 1 deletion
test/workers/branch/check-existing.spec.js
with
33 additions
and
1 deletion
lib/workers/branch/check-existing.js
+
25
−
0
View file @
7c410c12
const
moment
=
require
(
'
moment
'
);
module
.
exports
=
{
module
.
exports
=
{
prAlreadyExisted
,
prAlreadyExisted
,
};
};
...
@@ -14,6 +16,29 @@ async function prAlreadyExisted(config) {
...
@@ -14,6 +16,29 @@ async function prAlreadyExisted(config) {
// Check for current PR title format
// Check for current PR title format
if
(
await
config
.
api
.
checkForClosedPr
(
config
.
branchName
,
config
.
prTitle
))
{
if
(
await
config
.
api
.
checkForClosedPr
(
config
.
branchName
,
config
.
prTitle
))
{
logger
.
debug
(
'
Found closed PR with current title
'
);
logger
.
debug
(
'
Found closed PR with current title
'
);
// this code exists to ignore mistakenly closed PRs which occurred due to a bug
// TODO: Remove this by end of October 2017 or in v10
const
pr
=
await
config
.
api
.
findPr
(
config
.
branchName
,
config
.
prTitle
,
'
closed
'
);
if
(
pr
)
{
const
closedAt
=
moment
(
pr
.
closed_at
);
const
problemStart
=
moment
(
'
2017-10-15T20:00:00Z
'
);
const
problemStopped
=
moment
(
'
2017-10-16T06:00:00Z
'
);
logger
.
info
({
closedAt
,
problemStart
,
problemStopped
},
'
times
'
);
if
(
problemStart
.
isBefore
(
closedAt
)
&&
closedAt
.
isBefore
(
problemStopped
)
)
{
logger
.
info
(
{
closedAt
,
problemStart
,
problemStopped
},
'
Ignoring mistakenly closed PR
'
);
return
false
;
}
}
return
true
;
return
true
;
}
}
// Check for legacy PR title format
// Check for legacy PR title format
...
...
This diff is collapsed.
Click to expand it.
test/workers/branch/check-existing.spec.js
+
8
−
1
View file @
7c410c12
...
@@ -10,7 +10,7 @@ describe('workers/branch/check-existing', () => {
...
@@ -10,7 +10,7 @@ describe('workers/branch/check-existing', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
config
=
{
config
=
{
...
defaultConfig
,
...
defaultConfig
,
api
:
{
checkForClosedPr
:
jest
.
fn
()
},
api
:
{
checkForClosedPr
:
jest
.
fn
(),
findPr
:
jest
.
fn
()
},
logger
,
logger
,
branchName
:
'
some-branch
'
,
branchName
:
'
some-branch
'
,
prTitle
:
'
some-title
'
,
prTitle
:
'
some-title
'
,
...
@@ -37,5 +37,12 @@ describe('workers/branch/check-existing', () => {
...
@@ -37,5 +37,12 @@ describe('workers/branch/check-existing', () => {
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
true
);
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
true
);
expect
(
config
.
api
.
checkForClosedPr
.
mock
.
calls
.
length
).
toBe
(
2
);
expect
(
config
.
api
.
checkForClosedPr
.
mock
.
calls
.
length
).
toBe
(
2
);
});
});
it
(
'
returns false if mistaken
'
,
async
()
=>
{
config
.
api
.
checkForClosedPr
.
mockReturnValueOnce
(
true
);
config
.
api
.
findPr
.
mockReturnValueOnce
({
closed_at
:
'
2017-10-15T21:28:07.000Z
'
,
});
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
false
);
});
});
});
});
});
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