Skip to content

Commit

Permalink
added code to display version as commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ehearneRedHat committed May 22, 2024
1 parent 115d5a2 commit 4d98872
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ limitations under the License.
*/
package version

import (
"fmt"
"os/exec"
"strings"
)

func getCommitHash() string {
cmd := exec.Command("git", "rev-parse", "HEAD")
output, err := cmd.Output()
if err != nil {
fmt.Println("Error occurred while trying to retrieve the version of kuadrantctl. Do you have Git installed?")
return "v0.0.0"
}
commitHash := strings.TrimSpace(string(output))[:7]
return commitHash
}

var (
Version = "v0.0.0"
Version = "dev - " + getCommitHash()
)

0 comments on commit 4d98872

Please sign in to comment.