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
74ad0338
Unverified
Commit
74ad0338
authored
2 years ago
by
Adam Setch
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(changelog): use util/url instead of deprecated URL (#23113)
parent
bd3cf102
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/repository/update/pr/changelog/source.spec.ts
+44
-0
44 additions, 0 deletions
lib/workers/repository/update/pr/changelog/source.spec.ts
lib/workers/repository/update/pr/changelog/source.ts
+14
-9
14 additions, 9 deletions
lib/workers/repository/update/pr/changelog/source.ts
with
58 additions
and
9 deletions
lib/workers/repository/update/pr/changelog/source.spec.ts
0 → 100644
+
44
−
0
View file @
74ad0338
import
{
partial
}
from
'
../../../../../../test/util
'
;
import
type
{
BranchConfig
}
from
'
../../../../types
'
;
import
{
GitHubChangeLogSource
}
from
'
./github/source
'
;
const
changelogSource
=
new
GitHubChangeLogSource
();
const
upgrade
=
partial
<
BranchConfig
>
({
endpoint
:
'
https://api.github.com/
'
,
packageName
:
'
renovate
'
,
sourceUrl
:
'
https://github.com/renovatebot/renovate
'
,
});
describe
(
'
workers/repository/update/pr/changelog/source
'
,
()
=>
{
describe
(
'
getBaseUrl
'
,
()
=>
{
it
(
'
handles unsupported sourceUrl
'
,
()
=>
{
expect
(
changelogSource
.
getBaseUrl
({
...
upgrade
,
sourceUrl
:
undefined
,
})
).
toBeEmptyString
();
});
it
(
'
handles sourceUrl
'
,
()
=>
{
expect
(
changelogSource
.
getBaseUrl
(
upgrade
)).
toBe
(
'
https://github.com/
'
);
});
});
describe
(
'
getRepositoryFromUrl
'
,
()
=>
{
it
(
'
handles unsupported sourceUrl
'
,
()
=>
{
expect
(
changelogSource
.
getRepositoryFromUrl
({
...
upgrade
,
sourceUrl
:
undefined
,
})
).
toBeEmptyString
();
});
it
(
'
handles sourceUrl
'
,
()
=>
{
expect
(
changelogSource
.
getRepositoryFromUrl
(
upgrade
)).
toBe
(
'
renovatebot/renovate
'
);
});
});
});
This diff is collapsed.
Click to expand it.
lib/workers/repository/update/pr/changelog/source.ts
+
14
−
9
View file @
74ad0338
import
URL
from
'
node:url
'
;
import
is
from
'
@sindresorhus/is
'
;
import
is
from
'
@sindresorhus/is
'
;
import
{
logger
}
from
'
../../../../../logger
'
;
import
{
logger
}
from
'
../../../../../logger
'
;
import
{
getPkgReleases
}
from
'
../../../../../modules/datasource
'
;
import
{
getPkgReleases
}
from
'
../../../../../modules/datasource
'
;
...
@@ -6,7 +5,7 @@ import type { Release } from '../../../../../modules/datasource/types';
...
@@ -6,7 +5,7 @@ import type { Release } from '../../../../../modules/datasource/types';
import
*
as
allVersioning
from
'
../../../../../modules/versioning
'
;
import
*
as
allVersioning
from
'
../../../../../modules/versioning
'
;
import
*
as
packageCache
from
'
../../../../../util/cache/package
'
;
import
*
as
packageCache
from
'
../../../../../util/cache/package
'
;
import
{
regEx
}
from
'
../../../../../util/regex
'
;
import
{
regEx
}
from
'
../../../../../util/regex
'
;
import
{
trimSlashes
}
from
'
../../../../../util/url
'
;
import
{
parseUrl
,
trimSlashes
}
from
'
../../../../../util/url
'
;
import
type
{
BranchUpgradeConfig
}
from
'
../../../../types
'
;
import
type
{
BranchUpgradeConfig
}
from
'
../../../../types
'
;
import
{
slugifyUrl
}
from
'
./common
'
;
import
{
slugifyUrl
}
from
'
./common
'
;
import
{
addReleaseNotes
}
from
'
./release-notes
'
;
import
{
addReleaseNotes
}
from
'
./release-notes
'
;
...
@@ -238,16 +237,22 @@ export abstract class ChangeLogSource {
...
@@ -238,16 +237,22 @@ export abstract class ChangeLogSource {
return
`
${
slugifyUrl
(
sourceUrl
)}
:
${
packageName
}
:
${
prev
}
:
${
next
}
`
;
return
`
${
slugifyUrl
(
sourceUrl
)}
:
${
packageName
}
:
${
prev
}
:
${
next
}
`
;
}
}
protected
getBaseUrl
(
config
:
BranchUpgradeConfig
):
string
{
getBaseUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
URL
.
parse
(
config
.
sourceUrl
!
);
const
parsedUrl
=
parseUrl
(
config
.
sourceUrl
);
const
protocol
=
parsedUrl
.
protocol
!
;
if
(
is
.
nullOrUndefined
(
parsedUrl
))
{
const
host
=
parsedUrl
.
host
!
;
return
''
;
}
const
protocol
=
parsedUrl
.
protocol
;
const
host
=
parsedUrl
.
host
;
return
`
${
protocol
}
//
${
host
}
/`
;
return
`
${
protocol
}
//
${
host
}
/`
;
}
}
private
getRepositoryFromUrl
(
config
:
BranchUpgradeConfig
):
string
{
getRepositoryFromUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
URL
.
parse
(
config
.
sourceUrl
!
);
const
parsedUrl
=
parseUrl
(
config
.
sourceUrl
);
const
pathname
=
parsedUrl
.
pathname
!
;
if
(
is
.
nullOrUndefined
(
parsedUrl
))
{
return
''
;
}
const
pathname
=
parsedUrl
.
pathname
;
return
trimSlashes
(
pathname
).
replace
(
regEx
(
/
\.
git$/
),
''
);
return
trimSlashes
(
pathname
).
replace
(
regEx
(
/
\.
git$/
),
''
);
}
}
...
...
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