3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 02:32:39 +01:00

tweak version strings again

This commit is contained in:
Shivaram Lingamneni 2020-05-21 11:25:30 -04:00
parent 9d8b71b920
commit 464d0be949
5 changed files with 36 additions and 34 deletions

View File

@ -30,10 +30,6 @@ builds:
goarch: arm64
flags:
- -trimpath
# #1031: don't include the git hash in an official build
# default is: "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser"
ldflags:
- "-s -w -X main.build={{.Version}}"
archives:
-

View File

@ -1,6 +1,6 @@
.PHONY: all install build release capdefs test smoke
GIT_COMMIT := $(shell git rev-parse --short=16 HEAD 2> /dev/null)
GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null)
capdef_file = ./irc/caps/defs.go

View File

@ -5,20 +5,7 @@
package irc
import "fmt"
const (
// SemVer is the semantic version of Oragono.
SemVer = "2.1.0-unreleased"
)
var (
// Commit is the current git commit.
Commit = ""
// Ver is the full version of Oragono, used in responses to clients.
Ver = fmt.Sprintf("oragono-%s", SemVer)
// maxLastArgLength is used to simply cap off the final argument when creating general messages where we need to select a limit.
// for instance, in MONITOR lists, RPL_ISUPPORT lists, etc.
maxLastArgLength = 400

28
irc/version.go Normal file
View File

@ -0,0 +1,28 @@
// Copyright (c) 2020 Shivaram Lingamneni
// Released under the MIT license
package irc
import "fmt"
const (
// SemVer is the semantic version of Oragono.
SemVer = "2.1.0-unreleased"
)
var (
// Ver is the full version of Oragono, used in responses to clients.
Ver = fmt.Sprintf("oragono-%s", SemVer)
// Commit is the full git hash, if available
Commit string
)
// initialize version strings (these are set in package main via linker flags)
func SetVersionString(version, commit string) {
Commit = commit
if version != "" {
Ver = fmt.Sprintf("oragono-%s", version)
} else if len(Commit) == 40 {
Ver = fmt.Sprintf("oragono-%s-%s", SemVer, Commit[:16])
}
}

View File

@ -21,7 +21,9 @@ import (
"golang.org/x/crypto/ssh/terminal"
)
var commit = ""
// set via linker flags, either by make or by goreleaser:
var commit = "" // git hash
var version = "" // tagged version
// get a password from stdin from the user
func getPassword() string {
@ -89,7 +91,7 @@ func doMkcerts(configFile string, quiet bool) {
}
func main() {
version := irc.SemVer
irc.SetVersionString(version, commit)
usage := `oragono.
Usage:
oragono initdb [--conf <filename>] [--quiet]
@ -105,7 +107,7 @@ Options:
-h --help Show this screen.
--version Show version.`
arguments, _ := docopt.ParseArgs(usage, nil, version)
arguments, _ := docopt.ParseArgs(usage, nil, irc.Ver)
// don't require a config file for genpasswd
if arguments["genpasswd"].(bool) {
@ -167,22 +169,11 @@ Options:
}
} else if arguments["run"].(bool) {
if !arguments["--quiet"].(bool) {
logman.Info("server", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
if commit == "" {
logman.Debug("server", fmt.Sprintf("Could not get current commit"))
} else {
logman.Info("server", fmt.Sprintf("Running commit %s", commit))
}
}
// set current git commit
irc.Commit = commit
if commit != "" {
irc.Ver = fmt.Sprintf("%s-%s", irc.Ver, commit)
logman.Info("server", fmt.Sprintf("%s starting", irc.Ver))
}
// warning if running a non-final version
if strings.Contains(irc.SemVer, "unreleased") {
if strings.Contains(irc.Ver, "unreleased") {
logman.Warning("server", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.")
}