mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Fix latest version (#3464)
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
|||||||
const apiReleases string = "https://api.github.com/repos/stashapp/stash/releases"
|
const apiReleases string = "https://api.github.com/repos/stashapp/stash/releases"
|
||||||
const apiTags string = "https://api.github.com/repos/stashapp/stash/tags"
|
const apiTags string = "https://api.github.com/repos/stashapp/stash/tags"
|
||||||
const apiAcceptHeader string = "application/vnd.github.v3+json"
|
const apiAcceptHeader string = "application/vnd.github.v3+json"
|
||||||
|
const developmentTag string = "latest_develop"
|
||||||
const defaultSHLength int = 8 // default length of SHA short hash returned by <git rev-parse --short HEAD>
|
const defaultSHLength int = 8 // default length of SHA short hash returned by <git rev-parse --short HEAD>
|
||||||
|
|
||||||
var stashReleases = func() map[string]string {
|
var stashReleases = func() map[string]string {
|
||||||
@@ -168,22 +169,20 @@ func GetLatestRelease(ctx context.Context) (*LatestRelease, error) {
|
|||||||
platform := fmt.Sprintf("%s/%s", runtime.GOOS, arch)
|
platform := fmt.Sprintf("%s/%s", runtime.GOOS, arch)
|
||||||
wantedRelease := stashReleases()[platform]
|
wantedRelease := stashReleases()[platform]
|
||||||
|
|
||||||
var release githubReleasesResponse
|
url := apiReleases
|
||||||
if IsDevelop() {
|
if IsDevelop() {
|
||||||
// get the latest release, prerelease or not
|
// get the release tagged with the development tag
|
||||||
releases := []githubReleasesResponse{}
|
url += "/tags/" + developmentTag
|
||||||
err := makeGithubRequest(ctx, apiReleases+"?per_page=1", &releases)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
release = releases[0]
|
|
||||||
} else {
|
} else {
|
||||||
// just get the latest full release
|
// just get the latest full release
|
||||||
err := makeGithubRequest(ctx, apiReleases+"/latest", &release)
|
url += "/latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
var release githubReleasesResponse
|
||||||
|
err := makeGithubRequest(ctx, url, &release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
version := release.Name
|
version := release.Name
|
||||||
if release.Prerelease {
|
if release.Prerelease {
|
||||||
|
|||||||
Reference in New Issue
Block a user