diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c133f89..df54d9a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,7 +15,10 @@ builds: flags: - -trimpath ldflags: - - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.buildAt={{.Date}} + - -s -w + - -X github.com/ImSingee/kitty/internal/version.version={{.Version}} + - -X github.com/ImSingee/kitty/internal/version.commit={{.Commit}} + - -X github.com/ImSingee/kitty/internal/version.buildAt={{.Date}} archives: - format: tar.gz # this name template makes the OS and Arch compatible with the results of uname. diff --git a/cmd/kitty/main.go b/cmd/kitty/main.go index bcc0f7e..f9480ab 100644 --- a/cmd/kitty/main.go +++ b/cmd/kitty/main.go @@ -19,6 +19,7 @@ import ( "github.com/ImSingee/kitty/internal/lib/git" "github.com/ImSingee/kitty/internal/lib/xlog" "github.com/ImSingee/kitty/internal/tools" + "github.com/ImSingee/kitty/internal/version" _ "embed" ) @@ -34,7 +35,7 @@ func main() { app := &cobra.Command{ Use: "kitty [@extension]", Long: help, - Version: getVersionString(), + Version: version.GetVersionString(), SilenceUsage: true, SilenceErrors: true, } diff --git a/cmd/kitty/version.go b/cmd/kitty/version.go deleted file mode 100644 index 8b3d812..0000000 --- a/cmd/kitty/version.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import "fmt" - -var ( - version = "DEV" - commit = "" - buildAt = "" -) - -func getVersionString() string { - return fmt.Sprintf("%s\nCommit: %s\nBuild At: %s", version, commit, buildAt) -} diff --git a/go.mod b/go.mod index a8fc757..d0da0a2 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/ImSingee/tt v1.0.4 github.com/alessio/shellescape v1.4.2 github.com/charmbracelet/bubbletea v0.24.2 - github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.9.0 github.com/gobwas/glob v0.2.3 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 @@ -22,9 +21,9 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect diff --git a/go.sum b/go.sum index 15e4bac..a8ba501 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,6 @@ github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FD github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -27,7 +25,6 @@ github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrOb github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= @@ -57,7 +54,6 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs= github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..3fdbde6 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,23 @@ +package version + +import "fmt" + +var ( + version = "DEV" + commit = "" + buildAt = "" +) + +func Version() string { + return version +} +func Commit() string { + return commit +} +func BuildAt() string { + return buildAt +} + +func GetVersionString() string { + return fmt.Sprintf("%s\nCommit: %s\nBuild At: %s", version, commit, buildAt) +}