Skip to content

Commit

Permalink
[version] Support --build-options
Browse files Browse the repository at this point in the history
Ensure that all flags are forwarded to `git version`

Fixes #2440
  • Loading branch information
mislav committed Jan 21, 2020
1 parent 57b8337 commit 2b471bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
9 changes: 3 additions & 6 deletions commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commands

import (
"github.com/github/hub/ui"
"github.com/github/hub/utils"
"github.com/github/hub/version"
)

Expand All @@ -18,10 +17,8 @@ func init() {
}

func runVersion(cmd *Command, args *Args) {
output, err := version.FullVersion()
if output != "" {
ui.Println(output)
}
utils.Check(err)
versionCmd := args.ToCmd()
versionCmd.Spawn()
ui.Printf("hub version %s\n", version.Version)
args.NoForward()
}
10 changes: 7 additions & 3 deletions github/crash_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,23 @@ const crashReportTmpl = "Crash report - %v\n\n" +
"Error (%s): `%v`\n\n" +
"Stack:\n\n```\n%s\n```\n\n" +
"Runtime:\n\n```\n%s\n```\n\n" +
"Version:\n\n```\n%s\n```\n"
"Version:\n\n```\n%s\nhub version %s\n```\n"

func reportTitleAndBody(reportedError error, stack string) (title, body string, err error) {
errType := reflect.TypeOf(reportedError).String()
fullVersion, _ := version.FullVersion()
gitVersion, gitErr := git.Version()
if gitErr != nil {
gitVersion = "git unavailable!"
}
message := fmt.Sprintf(
crashReportTmpl,
reportedError,
errType,
reportedError,
stack,
runtimeInfo(),
fullVersion,
gitVersion,
version.Version,
)

messageBuilder := &MessageBuilder{
Expand Down
15 changes: 1 addition & 14 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
package version

import (
"fmt"

"github.com/github/hub/git"
)

// Version represents the hub version number
var Version = "2.13.0"

func FullVersion() (string, error) {
gitVersion, err := git.Version()
if err != nil {
gitVersion = "git version (unavailable)"
}
return fmt.Sprintf("%s\nhub version %s", gitVersion, Version), err
}

0 comments on commit 2b471bd

Please sign in to comment.