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
fa71763a
Unverified
Commit
fa71763a
authored
3 years ago
by
Sergei Zharinov
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(gitlab): Extract getSourceUrl function (#12511)
parent
3cd70f8c
No related branches found
Branches containing commit
Tags
12.31.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/datasource/gitlab-tags/index.ts
+4
-4
4 additions, 4 deletions
lib/datasource/gitlab-tags/index.ts
lib/datasource/gitlab-tags/util.ts
+13
-0
13 additions, 0 deletions
lib/datasource/gitlab-tags/util.ts
with
17 additions
and
4 deletions
lib/datasource/gitlab-tags/index.ts
+
4
−
4
View file @
fa71763a
import
*
as
packageCache
from
'
../../util/cache/package
'
;
import
*
as
packageCache
from
'
../../util/cache/package
'
;
import
{
GitlabHttp
}
from
'
../../util/http/gitlab
'
;
import
{
GitlabHttp
}
from
'
../../util/http/gitlab
'
;
import
{
regEx
}
from
'
../../util/regex
'
;
import
{
joinUrlParts
}
from
'
../../util/url
'
;
import
{
joinUrlParts
}
from
'
../../util/url
'
;
import
type
{
GetReleasesConfig
,
ReleaseResult
}
from
'
../types
'
;
import
type
{
GetReleasesConfig
,
ReleaseResult
}
from
'
../types
'
;
import
type
{
GitlabTag
}
from
'
./types
'
;
import
type
{
GitlabTag
}
from
'
./types
'
;
import
{
defaultRegistryUrl
,
getDepHost
,
getSourceUrl
}
from
'
./util
'
;
export
const
id
=
'
gitlab-tags
'
;
export
const
id
=
'
gitlab-tags
'
;
const
gitlabApi
=
new
GitlabHttp
(
id
);
const
gitlabApi
=
new
GitlabHttp
(
id
);
export
const
customRegistrySupport
=
true
;
export
const
customRegistrySupport
=
true
;
export
const
defaultRegistryUrls
=
[
'
https://gitlab.com
'
];
export
const
defaultRegistryUrls
=
[
defaultRegistryUrl
];
export
const
registryStrategy
=
'
first
'
;
export
const
registryStrategy
=
'
first
'
;
const
cacheNamespace
=
'
datasource-gitlab
'
;
const
cacheNamespace
=
'
datasource-gitlab
'
;
...
@@ -23,7 +23,7 @@ export async function getReleases({
...
@@ -23,7 +23,7 @@ export async function getReleases({
registryUrl
,
registryUrl
,
lookupName
:
repo
,
lookupName
:
repo
,
}:
GetReleasesConfig
):
Promise
<
ReleaseResult
|
null
>
{
}:
GetReleasesConfig
):
Promise
<
ReleaseResult
|
null
>
{
const
depHost
=
registryUrl
.
replace
(
regEx
(
/
\/
api
\/
v4$/
),
''
);
const
depHost
=
getDepHost
(
registryUrl
);
const
cachedResult
=
await
packageCache
.
get
<
ReleaseResult
>
(
const
cachedResult
=
await
packageCache
.
get
<
ReleaseResult
>
(
cacheNamespace
,
cacheNamespace
,
...
@@ -51,7 +51,7 @@ export async function getReleases({
...
@@ -51,7 +51,7 @@ export async function getReleases({
).
body
;
).
body
;
const
dependency
:
ReleaseResult
=
{
const
dependency
:
ReleaseResult
=
{
sourceUrl
:
joinUrlParts
(
depHost
,
repo
),
sourceUrl
:
getSourceUrl
(
repo
,
registryUrl
),
releases
:
null
,
releases
:
null
,
};
};
dependency
.
releases
=
gitlabTags
.
map
(({
name
,
commit
})
=>
({
dependency
.
releases
=
gitlabTags
.
map
(({
name
,
commit
})
=>
({
...
...
This diff is collapsed.
Click to expand it.
lib/datasource/gitlab-tags/util.ts
0 → 100644
+
13
−
0
View file @
fa71763a
import
{
regEx
}
from
'
../../util/regex
'
;
import
{
joinUrlParts
}
from
'
../../util/url
'
;
export
const
defaultRegistryUrl
=
'
https://gitlab.com
'
;
export
function
getDepHost
(
registryUrl
:
string
=
defaultRegistryUrl
):
string
{
return
registryUrl
.
replace
(
regEx
(
/
\/
api
\/
v4$/
),
''
);
}
export
function
getSourceUrl
(
lookupName
:
string
,
registryUrl
?:
string
):
string
{
const
depHost
=
getDepHost
(
registryUrl
);
return
joinUrlParts
(
depHost
,
lookupName
);
}
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