Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dokumentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
Dokumentation
Commits
054b0381
Verified
Commit
054b0381
authored
3 years ago
by
Florian Kaufmann
Browse files
Options
Downloads
Patches
Plain Diff
Wiedereinführung der latest version für die Submission Api
parent
21e11996
No related branches found
Branches containing commit
No related tags found
1 merge request
!71
Wiedereinführung der latest version für die Submission Api
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/apis/submission-api.mdx
+1
-1
1 addition, 1 deletion
docs/apis/submission-api.mdx
src/utils/getLatestVersion.js
+18
-14
18 additions, 14 deletions
src/utils/getLatestVersion.js
with
19 additions
and
15 deletions
docs/apis/submission-api.mdx
+
1
−
1
View file @
054b0381
...
...
@@ -5,4 +5,4 @@ hide_table_of_contents: true
import ApiSpec from '@site/src/components/ApiSpec'
<ApiSpec gitlabProjectId={"1"} path={"submission-api"} artifact={"submission-api.yaml"} includePrerelease = {true} />
<ApiSpec gitlabProjectId={"1"} path={"submission-api"} artifact={"submission-api.yaml"} includePrerelease = {true}
version = {"latest"}
/>
This diff is collapsed.
Click to expand it.
src/utils/getLatestVersion.js
+
18
−
14
View file @
054b0381
...
...
@@ -2,19 +2,23 @@ import axios from "axios";
import
semver
from
"
semver
"
;
export
default
async
function
({
siteVersion
,
projectId
,
includePrerelease
=
false
})
{
return
axios
.
get
(
`https://git.fitko.de/api/v4/projects/
${
projectId
}
/repository/tags`
)
.
catch
((
error
)
=>
{
throw
`Fetching of latest tags failed with
${
error
.
response
.
status
}
`
})
.
then
(
async
({
data
})
=>
{
const
versionRange
=
`~
${
siteVersion
}
`
const
suitableVersions
=
await
data
.
filter
(({
name
})
=>
semver
.
satisfies
(
name
,
versionRange
,
{
includePrerelease
}))
.
map
(({
name
})
=>
name
)
.
sort
()
if
(
siteVersion
===
'
latest
'
)
{
return
'
latest
'
}
else
{
return
axios
.
get
(
`https://git.fitko.de/api/v4/projects/
${
projectId
}
/repository/tags`
)
.
catch
((
error
)
=>
{
throw
`Fetching of latest tags failed with
${
error
.
response
.
status
}
`
})
.
then
(
async
({
data
})
=>
{
const
versionRange
=
`~
${
siteVersion
}
`
const
suitableVersions
=
await
data
.
filter
(({
name
})
=>
semver
.
satisfies
(
name
,
versionRange
,
{
includePrerelease
}))
.
map
(({
name
})
=>
name
)
.
sort
()
const
result_version
=
semver
.
maxSatisfying
(
suitableVersions
,
versionRange
,
{
includePrerelease
})
console
.
log
(
'
Get version for project: %s, requested version: %s, includePrerelease: %s, available versions: %s, selected version: %s
'
,
projectId
,
siteVersion
,
includePrerelease
,
suitableVersions
,
result_version
)
return
result_version
})
const
result_version
=
semver
.
maxSatisfying
(
suitableVersions
,
versionRange
,
{
includePrerelease
})
console
.
log
(
'
Get version for project: %s, requested version: %s, includePrerelease: %s, available versions: %s, selected version: %s
'
,
projectId
,
siteVersion
,
includePrerelease
,
suitableVersions
,
result_version
)
return
result_version
})
}
}
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