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
74ad0338
Unverified
Commit
74ad0338
authored
1 year ago
by
Adam Setch
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(changelog): use util/url instead of deprecated URL (#23113)
parent
bd3cf102
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide 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
{
logger
}
from
'
../../../../../logger
'
;
import
{
getPkgReleases
}
from
'
../../../../../modules/datasource
'
;
...
...
@@ -6,7 +5,7 @@ import type { Release } from '../../../../../modules/datasource/types';
import
*
as
allVersioning
from
'
../../../../../modules/versioning
'
;
import
*
as
packageCache
from
'
../../../../../util/cache/package
'
;
import
{
regEx
}
from
'
../../../../../util/regex
'
;
import
{
trimSlashes
}
from
'
../../../../../util/url
'
;
import
{
parseUrl
,
trimSlashes
}
from
'
../../../../../util/url
'
;
import
type
{
BranchUpgradeConfig
}
from
'
../../../../types
'
;
import
{
slugifyUrl
}
from
'
./common
'
;
import
{
addReleaseNotes
}
from
'
./release-notes
'
;
...
...
@@ -238,16 +237,22 @@ export abstract class ChangeLogSource {
return
`
${
slugifyUrl
(
sourceUrl
)}
:
${
packageName
}
:
${
prev
}
:
${
next
}
`
;
}
protected
getBaseUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
URL
.
parse
(
config
.
sourceUrl
!
);
const
protocol
=
parsedUrl
.
protocol
!
;
const
host
=
parsedUrl
.
host
!
;
getBaseUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
parseUrl
(
config
.
sourceUrl
);
if
(
is
.
nullOrUndefined
(
parsedUrl
))
{
return
''
;
}
const
protocol
=
parsedUrl
.
protocol
;
const
host
=
parsedUrl
.
host
;
return
`
${
protocol
}
//
${
host
}
/`
;
}
private
getRepositoryFromUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
URL
.
parse
(
config
.
sourceUrl
!
);
const
pathname
=
parsedUrl
.
pathname
!
;
getRepositoryFromUrl
(
config
:
BranchUpgradeConfig
):
string
{
const
parsedUrl
=
parseUrl
(
config
.
sourceUrl
);
if
(
is
.
nullOrUndefined
(
parsedUrl
))
{
return
''
;
}
const
pathname
=
parsedUrl
.
pathname
;
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