Add additional latest version info (#3357)

This commit is contained in:
DingDongSoLong4
2023-02-08 06:02:23 +02:00
committed by GitHub
parent cb808c7be2
commit 901a7e59ec
8 changed files with 206 additions and 167 deletions

View File

@@ -11,6 +11,7 @@ import (
"net/http"
"os"
"path"
"regexp"
"runtime/debug"
"strconv"
"strings"
@@ -392,22 +393,48 @@ func javascriptHandler(c *config.Instance, pluginCache *plugin.Cache) func(w htt
}
func printVersion() {
versionString := githash
var versionString string
switch {
case version != "":
if githash != "" && !IsDevelop() {
versionString = version + " (" + githash + ")"
} else {
versionString = version
}
case githash != "":
versionString = githash
default:
versionString = "unknown"
}
if config.IsOfficialBuild() {
versionString += " - Official Build"
} else {
versionString += " - Unofficial Build"
}
if version != "" {
versionString = version + " (" + versionString + ")"
if buildstamp != "" {
versionString += " - " + buildstamp
}
fmt.Printf("stash version: %s - %s\n", versionString, buildstamp)
logger.Infof("stash version: %s\n", versionString)
}
func GetVersion() (string, string, string) {
return version, githash, buildstamp
}
func IsDevelop() bool {
if githash == "" {
return false
}
// if the version is suffixed with -x-xxxx, then we are running a development build
develop := false
re := regexp.MustCompile(`-\d+-g\w+$`)
if re.MatchString(version) {
develop = true
}
return develop
}
func makeTLSConfig(c *config.Instance) (*tls.Config, error) {
c.InitTLS()
certFile, keyFile := c.GetTLSFiles()
@@ -428,12 +455,12 @@ func makeTLSConfig(c *config.Instance) (*tls.Config, error) {
cert, err := os.ReadFile(certFile)
if err != nil {
return nil, fmt.Errorf("error reading SSL certificate file %s: %s", certFile, err.Error())
return nil, fmt.Errorf("error reading SSL certificate file %s: %v", certFile, err)
}
key, err := os.ReadFile(keyFile)
if err != nil {
return nil, fmt.Errorf("error reading SSL key file %s: %s", keyFile, err.Error())
return nil, fmt.Errorf("error reading SSL key file %s: %v", keyFile, err)
}
certs := make([]tls.Certificate, 1)