Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
19116fc6
Commit
19116fc6
authored
6 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
refactor: remove legacy closed PR check
parent
6d9ba068
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/branch/check-existing.js
+1
-22
1 addition, 22 deletions
lib/workers/branch/check-existing.js
test/workers/branch/check-existing.spec.js
+2
-8
2 additions, 8 deletions
test/workers/branch/check-existing.spec.js
with
3 additions
and
30 deletions
lib/workers/branch/check-existing.js
+
1
−
22
View file @
19116fc6
...
@@ -10,32 +10,11 @@ async function prAlreadyExisted(config) {
...
@@ -10,32 +10,11 @@ async function prAlreadyExisted(config) {
}
}
logger
.
debug
(
'
recreateClosed is false
'
);
logger
.
debug
(
'
recreateClosed is false
'
);
// Return if same PR already existed
// Return if same PR already existed
// Check for current PR title format
const
pr
=
await
platform
.
findPr
(
config
.
branchName
,
config
.
prTitle
,
'
!open
'
);
// See #1205 for why we check for !open or closed
const
statusValue
=
config
.
packageFiles
&&
config
.
packageFiles
.
length
===
1
?
'
!open
'
:
'
closed
'
;
let
pr
=
await
platform
.
findPr
(
config
.
branchName
,
config
.
prTitle
,
statusValue
);
if
(
pr
)
{
if
(
pr
)
{
logger
.
debug
(
'
Found closed PR with current title
'
);
logger
.
debug
(
'
Found closed PR with current title
'
);
return
pr
;
return
pr
;
}
}
// Check for legacy PR title format
// TODO: remove this once not found anymore
const
legacyPrTitle
=
config
.
prTitle
.
replace
(
/to v
(\d
+
)
$/
,
'
to version $1.x
'
)
// Major
.
replace
(
/to v
(\d
+
)
/
,
'
to version $1
'
);
// Non-major
pr
=
await
platform
.
findPr
(
config
.
branchName
,
legacyPrTitle
,
statusValue
);
if
(
pr
)
{
logger
.
info
({
pr
},
'
Found closed PR with legacy title
'
);
await
platform
.
updatePr
(
pr
.
number
,
config
.
prTitle
);
return
pr
;
}
logger
.
debug
(
'
prAlreadyExisted=false
'
);
logger
.
debug
(
'
prAlreadyExisted=false
'
);
return
null
;
return
null
;
}
}
This diff is collapsed.
Click to expand it.
test/workers/branch/check-existing.spec.js
+
2
−
8
View file @
19116fc6
...
@@ -19,21 +19,15 @@ describe('workers/branch/check-existing', () => {
...
@@ -19,21 +19,15 @@ describe('workers/branch/check-existing', () => {
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
null
);
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
null
);
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
0
);
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
0
);
});
});
it
(
'
returns false if
both
check
s
miss
'
,
async
()
=>
{
it
(
'
returns false if check miss
es
'
,
async
()
=>
{
config
.
recreatedClosed
=
true
;
config
.
recreatedClosed
=
true
;
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
null
);
expect
(
await
prAlreadyExisted
(
config
)).
toBe
(
null
);
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
2
);
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
1
);
});
});
it
(
'
returns true if first check hits
'
,
async
()
=>
{
it
(
'
returns true if first check hits
'
,
async
()
=>
{
platform
.
findPr
.
mockReturnValueOnce
({
number
:
12
});
platform
.
findPr
.
mockReturnValueOnce
({
number
:
12
});
expect
(
await
prAlreadyExisted
(
config
)).
toEqual
({
number
:
12
});
expect
(
await
prAlreadyExisted
(
config
)).
toEqual
({
number
:
12
});
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
1
);
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
1
);
});
});
it
(
'
returns true if second check hits
'
,
async
()
=>
{
platform
.
findPr
.
mockReturnValueOnce
(
null
);
platform
.
findPr
.
mockReturnValueOnce
({
number
:
13
});
expect
(
await
prAlreadyExisted
(
config
)).
toEqual
({
number
:
13
});
expect
(
platform
.
findPr
.
mock
.
calls
.
length
).
toBe
(
2
);
});
});
});
});
});
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