Skip to content

Commit

Permalink
Merge pull request #60 from getsolus/add-version
Browse files Browse the repository at this point in the history
Add version to User-Agent
  • Loading branch information
ReillyBrogan authored Dec 19, 2023
2 parents e376f80 + a476a1d commit dca6dc0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BINNAME := solbuild

.PHONY: build
build:
go build -o bin/$(BINNAME) $(CURDIR)/main.go
go build -ldflags "-X github.com/getsolus/solbuild/util.SolbuildVersion=$(VERSION)" -o bin/$(BINNAME) $(CURDIR)/main.go

.PHONY: install
install:
Expand Down
4 changes: 3 additions & 1 deletion builder/source/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (

"github.com/cavaliergopher/grab/v3"
"github.com/cheggaaa/pb/v3"

"github.com/getsolus/solbuild/util"
)

const progressBarTemplate string = `{{with string . "prefix"}}{{.}} {{end}}{{printf "%25s" (counters .) }} {{bar . }} {{printf "%7s" (percent .) }} {{printf "%14s" (speed . "%s/s" "??/s")}}{{with string . "suffix"}} {{.}}{{end}}`
Expand Down Expand Up @@ -144,7 +146,7 @@ func (s *SimpleSource) download(destination string) error {
// Create a client with compression disabled.
// See: https://github.com/cavaliergopher/grab/blob/v3.0.1/v3/client.go#L53
client := &grab.Client{
UserAgent: "solbuild",
UserAgent: "solbuild/" + util.SolbuildVersion,
HTTPClient: &http.Client{
Transport: &http.Transport{
DisableCompression: true,
Expand Down
7 changes: 2 additions & 5 deletions cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ import (
"fmt"

"github.com/DataDrake/cli-ng/v2/cmd"
)

const (
// SolbuildVersion is the current public version of solbuild.
SolbuildVersion = "1.5.3.0"
"github.com/getsolus/solbuild/util"
)

func init() {
Expand All @@ -42,6 +39,6 @@ var Version = cmd.Sub{
//
//nolint:forbidigo // the point of this function is to print the version
func VersionRun(_ *cmd.Root, _ *cmd.Sub) {
fmt.Printf("solbuild version %v\n\nCopyright © 2016-2021 Solus Project\n", SolbuildVersion)
fmt.Printf("solbuild version %v\n\nCopyright © 2016-2021 Solus Project\n", util.SolbuildVersion)
fmt.Println("Licensed under the Apache License, Version 2.0")
}
19 changes: 19 additions & 0 deletions util/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright © 2016-2021 Solus Project <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package util

var SolbuildVersion = "development"

0 comments on commit dca6dc0

Please sign in to comment.