Skip to content

Commit

Permalink
Remove commit revision in version command (#905)
Browse files Browse the repository at this point in the history
The error occurs when running `$ yorkie version`. The cause was not
found, but since revision wasn't strictly necessary, this commit
removes revision from version command.
  • Loading branch information
hackerwins authored Jun 20, 2024
1 parent 47ae9d4 commit 1df48f5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
20 changes: 0 additions & 20 deletions cmd/yorkie/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,25 @@ package main
import (
"fmt"
"runtime"
"runtime/debug"

"github.com/spf13/cobra"

"github.com/yorkie-team/yorkie/internal/version"
)

const commitRevisionKey = "vcs.revision"

func newVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print the version number of Yorkie",
RunE: func(cmd *cobra.Command, args []string) error {
revision := settingByKey(commitRevisionKey)
fmt.Printf("Yorkie: %s\n", version.Version)
fmt.Printf("Commit: %s\n", revision[:7])
fmt.Printf("Go: %s\n", runtime.Version())
fmt.Printf("Build date: %s\n", version.BuildDate)
return nil
},
}
}

func settingByKey(key string) string {
info, ok := debug.ReadBuildInfo()
if !ok {
return ""
}

for _, setting := range info.Settings {
if setting.Key == key {
return setting.Value
}
}

return ""
}

func init() {
rootCmd.AddCommand(newVersionCmd())
}
2 changes: 1 addition & 1 deletion server/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func New(
}

logging.DefaultLogger().Infof(
"backend created: id: %s, rpc: %s",
"backend created: id: %s, db: %s",
serverInfo.ID,
dbInfo,
)
Expand Down

0 comments on commit 1df48f5

Please sign in to comment.