removing build date and adding goarch

This commit is contained in:
Gary Holtz 2023-03-08 14:06:54 -06:00
parent f8fe098666
commit e2da96779b
No known key found for this signature in database
GPG Key ID: 0C3B92677CFEE92F
3 changed files with 13 additions and 11 deletions

View File

@ -28,7 +28,7 @@ const (
)
type glabInstall struct {
version, platform, build string
version, platform, architecture string
}
var currentGlabInstall glabInstall
@ -62,14 +62,14 @@ type Client struct {
func (i glabInstall) UserAgent() string {
// UserAgent format: glab/v1.25.3-27-g7ec258fb - built 2023-02-16, (darwin)
return fmt.Sprintf("glab/%s - built %s, (%s)", i.version, i.build, i.platform)
return fmt.Sprintf("glab/%s (%s, %s)", i.version, i.platform, i.architecture)
}
func SetUserAgent(version string, build string, platform string) {
func SetUserAgent(version string, platform string, architecture string) {
currentGlabInstall = glabInstall{
version: version,
build: build,
platform: platform,
version: version,
platform: platform,
architecture: architecture,
}
}

View File

@ -6,6 +6,7 @@ import (
"net"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
@ -57,7 +58,7 @@ func main() {
os.Exit(2)
}
api.SetUserAgent(version, buildDate, platform)
api.SetUserAgent(version, platform, runtime.GOARCH)
maybeOverrideDefaultHost(cmdFactory, cfg)
if !cmdFactory.IO.ColorEnabled() {

View File

@ -96,14 +96,15 @@ hosts:
username: monalisa
token: OTOKEN
`, "")()
originalEnvVarToken, envIsSet := os.LookupEnv("GITLAB_TOKEN")
api.SetUserAgent("v1.2.3", "12-31-1999", "darwin")
versionString := "glab/v1.2.3 - built 12-31-1999, (darwin)"
if envIsSet && originalEnvVarToken != "" {
_ = os.Setenv("GITLAB_TOKEN", "")
}
api.SetUserAgent("v1.2.3", "darwin", "arm64")
versionString := "glab/v1.2.3 (darwin, arm64)"
client := &http.Client{}
client.Transport = roundTripFunc(func(req *http.Request) (*http.Response, error) {
t.Log("Tsti")