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
fa25de1c
Unverified
Commit
fa25de1c
authored
3 years ago
by
Michael Kriese
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: cleanup datasource code (#10500)
parent
926a076f
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/datasource/index.ts
+10
-13
10 additions, 13 deletions
lib/datasource/index.ts
with
10 additions
and
13 deletions
lib/datasource/index.ts
+
10
−
13
View file @
fa25de1c
...
...
@@ -15,7 +15,6 @@ import type {
DigestConfig
,
GetPkgReleasesConfig
,
GetReleasesConfig
,
Release
,
ReleaseResult
,
}
from
'
./types
'
;
...
...
@@ -33,7 +32,8 @@ function getDatasourceFor(datasource: string): DatasourceApi {
type
GetReleasesInternalConfig
=
GetReleasesConfig
&
GetPkgReleasesConfig
;
function
logError
(
datasource
,
lookupName
,
err
):
void
{
// TODO: fix error Type
function
logError
(
datasource
:
string
,
lookupName
:
string
,
err
:
any
):
void
{
const
{
statusCode
,
code
:
errCode
,
url
}
=
err
;
if
(
statusCode
===
404
)
{
logger
.
debug
({
datasource
,
lookupName
,
url
},
'
Datasource 404
'
);
...
...
@@ -100,7 +100,7 @@ async function huntRegistries(
registryUrls
:
string
[]
):
Promise
<
ReleaseResult
>
{
let
res
:
ReleaseResult
;
let
caughtError
;
let
caughtError
:
Error
;
for
(
const
registryUrl
of
registryUrls
)
{
try
{
res
=
await
getRegistryReleases
(
datasource
,
config
,
registryUrl
);
...
...
@@ -131,7 +131,7 @@ async function mergeRegistries(
registryUrls
:
string
[]
):
Promise
<
ReleaseResult
>
{
let
combinedRes
:
ReleaseResult
;
let
caughtError
;
let
caughtError
:
Error
;
for
(
const
registryUrl
of
registryUrls
)
{
try
{
const
res
=
await
getRegistryReleases
(
datasource
,
config
,
registryUrl
);
...
...
@@ -313,15 +313,12 @@ export async function getPkgReleases(
const
versioning
=
config
.
versioning
||
getDefaultVersioning
(
config
.
datasource
);
const
version
=
allVersioning
.
get
(
versioning
);
// Return a sorted list of valid Versions
function
sortReleases
(
release1
:
Release
,
release2
:
Release
):
number
{
return
version
.
sortVersions
(
release1
.
version
,
release2
.
version
);
}
if
(
res
.
releases
)
{
res
.
releases
=
res
.
releases
.
filter
((
release
)
=>
version
.
isVersion
(
release
.
version
))
.
sort
(
sortReleases
);
}
// Filter and sort valid versions
res
.
releases
=
res
.
releases
.
filter
((
release
)
=>
version
.
isVersion
(
release
.
version
))
.
sort
((
a
,
b
)
=>
version
.
sortVersions
(
a
.
version
,
b
.
version
));
// Filter versions for uniqueness
res
.
releases
=
res
.
releases
.
filter
(
(
filterRelease
,
filterIndex
)
=>
...
...
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