Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ YEAR_GEN := $(shell date '+%Y')
.PHONY: docs fix vet fmt lint test build tidy release release-ci

GOBIN := $(shell go env GOPATH)/bin
GIT_COMMIT := $(shell git rev-parse --short HEAD)
KPT_VERSION := $(shell date '+development-%Y-%m-%dT%H:%M:%S')

export KPT_FN_WASM_RUNTIME ?= nodejs

LDFLAGS := -ldflags "-X github.com/kptdev/kpt/run.version=${GIT_COMMIT}
LDFLAGS := -ldflags "-X github.com/kptdev/kpt/run.version=${KPT_VERSION}
Comment thread
aravindtga marked this conversation as resolved.
ifeq ($(OS),Windows_NT)
# Do nothing
else
Expand Down
19 changes: 17 additions & 2 deletions run/run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 The kpt Authors
// Copyright 2019-2026 The kpt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"os/exec"
"runtime/debug"
"strconv"
"strings"

Expand Down Expand Up @@ -159,7 +160,21 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of kpt",
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("%s\n", version)
var hash, dirty string
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
switch setting.Key {
case "vcs.revision":
hash = setting.Value
case "vcs.modified":
if strings.ToLower(setting.Value) == "true" {
dirty = " (dirty)"
}
}
}
}
Comment thread
aravindtga marked this conversation as resolved.
fmt.Printf("Version: %s\n", version)
fmt.Printf("Git commit: %s%s\n", hash, dirty)
},
}

Expand Down
Loading