Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gitVersion in makefile #725

Merged
merged 1 commit into from
Mar 28, 2023
Merged

Conversation

2456868764
Copy link
Contributor

What type of PR is this?

make gitVersion problem in make file

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Copy link
Member

@qmhu qmhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please provide more information about current problem and how it fix?

@2456868764
Copy link
Contributor Author

Would you please provide more information about current problem and how it fix?

  1. this is version.go code :

`package version

import (
"encoding/json"
"fmt"
"runtime"
)

var (
gitVersion = "crane-%s"
gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState = "" // state of git tree, either "clean" or "dirty"
gitTag = ""
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
)

type Version struct {
GitVersion string json:"gitVersion"
GitCommit string json:"gitCommit"
BuildDate string json:"buildDate"
GoVersion string json:"goVersion"
Compiler string json:"compiler"
Platform string json:"platform"
GitTreeState string json:"gitTreeState"
}

func GetVersionInfo() string {
ver := Version{
GitVersion: fmt.Sprintf(gitVersion, gitTag),
GitCommit: gitCommit,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
GitTreeState: gitTreeState,
}
res, _ := json.Marshal(ver)
return string(res)
}`

  1. according to code : ”GitVersion: fmt.Sprintf(gitVersion, gitTag),“
    so gitVersion will be replaced by the current gitTag when it is built, and not started with "crane-".

To fix this bug, gitTag will be replaced when it's built , and gitVersion will be started with "crane-" .

@qmhu qmhu merged commit bb40f6e into gocrane:main Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants