Skip to content

Commit

Permalink
Add doctor version check (#318)
Browse files Browse the repository at this point in the history
Add doctor version check
  • Loading branch information
twpayne committed May 20, 2019
2 parents 36bbdcd + 2566544 commit d17f54f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
26 changes: 26 additions & 0 deletions cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type doctorSuspiciousFilesCheck struct {
found []string
}

type doctorVersionCheck struct{}

func init() {
rootCmd.AddCommand(doctorCmd)
}
Expand All @@ -98,6 +100,7 @@ func (c *Config) runDoctorCmd(fs vfs.FS, args []string) error {

allOK := true
for _, dc := range []doctorCheck{
&doctorVersionCheck{},
&doctorDirectoryCheck{
name: "source directory",
path: c.SourceDir,
Expand Down Expand Up @@ -379,3 +382,26 @@ func (c *doctorSuspiciousFilesCheck) Result() string {
func (c *doctorSuspiciousFilesCheck) Skip() bool {
return false
}

func (doctorVersionCheck) Check() (bool, error) {
if VersionStr == devVersionStr || Commit == unknownStr || Date == unknownStr {
return false, nil
}
return true, nil
}

func (doctorVersionCheck) Enabled() bool {
return true
}

func (doctorVersionCheck) MustSucceed() bool {
return false
}

func (doctorVersionCheck) Result() string {
return "version " + rootCmd.Version
}

func (doctorVersionCheck) Skip() bool {
return false
}
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ var config = Config{
// Version information.
var (
devVersionStr = "dev"
unknownStr = "unknown"
VersionStr = devVersionStr
Commit = "unknown"
Date = "unknown"
Commit = unknownStr
Date = unknownStr
Version *semver.Version
)

Expand Down

0 comments on commit d17f54f

Please sign in to comment.