mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add -v/--version flag to print version string (#3883)
* Add `-v/--version` flag to print version string - Created a new flag `-v/--version` in the command-line interface to display the version number and exit. - Moved all version-related functions inside the config package to the new file `manager/config/version.go` to avoid circular dependencies. - Added a new `GetVersionString()` function to generate a formatted version string. - Updated references to the moved version functions. - Updated references in the `Makefile`. * Move version embeds to build package * Remove githash var --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"golang.org/x/sys/cpu"
|
||||
|
||||
"github.com/stashapp/stash/internal/build"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
@@ -170,7 +171,7 @@ func GetLatestRelease(ctx context.Context) (*LatestRelease, error) {
|
||||
wantedRelease := stashReleases()[platform]
|
||||
|
||||
url := apiReleases
|
||||
if IsDevelop() {
|
||||
if build.IsDevelop() {
|
||||
// get the release tagged with the development tag
|
||||
url += "/tags/" + developmentTag
|
||||
} else {
|
||||
@@ -213,7 +214,7 @@ func GetLatestRelease(ctx context.Context) (*LatestRelease, error) {
|
||||
}
|
||||
}
|
||||
|
||||
_, githash, _ := GetVersion()
|
||||
_, githash, _ := build.Version()
|
||||
shLength := len(githash)
|
||||
if shLength == 0 {
|
||||
shLength = defaultSHLength
|
||||
@@ -273,7 +274,7 @@ func printLatestVersion(ctx context.Context) {
|
||||
if err != nil {
|
||||
logger.Errorf("Couldn't retrieve latest version: %v", err)
|
||||
} else {
|
||||
_, githash, _ = GetVersion()
|
||||
_, githash, _ := build.Version()
|
||||
switch {
|
||||
case githash == "":
|
||||
logger.Infof("Latest version: %s (%s)", latestRelease.Version, latestRelease.ShortHash)
|
||||
|
||||
Reference in New Issue
Block a user