Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
fix(status): add shortRev and longRev for latest
Browse files Browse the repository at this point in the history
Adds options to specify shortRev or longRev to getConsolidatedLatest().
  • Loading branch information
darkowlzz committed Sep 10, 2017
1 parent e21b71f commit 4621913
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ print an extended status output for each dependency of the project.
Status returns exit code zero if all dependencies are in a "good state".
`

const (
shortRev = iota
longRev = iota
)

var (
errFailedUpdate = errors.New("failed to fetch updates")
errFailedListPkg = errors.New("failed to list packages")
Expand Down Expand Up @@ -104,7 +109,7 @@ func (out *tableOutput) BasicLine(bs *BasicStatus) {
bs.getConsolidatedConstraint(),
formatVersion(bs.Version),
formatVersion(bs.Revision),
bs.getConsolidatedLatest(),
bs.getConsolidatedLatest(shortRev),
bs.PackageCount,
)
}
Expand Down Expand Up @@ -308,10 +313,15 @@ func (bs *BasicStatus) getConsolidatedVersion() string {
return version
}

func (bs *BasicStatus) getConsolidatedLatest() string {
func (bs *BasicStatus) getConsolidatedLatest(revSize int) string {
latest := ""
if bs.Latest != nil {
latest = formatVersion(bs.Latest)
switch revSize {
case shortRev:
latest = formatVersion(bs.Latest)
case longRev:
latest = bs.Latest.String()
}
}

if bs.hasError {
Expand All @@ -326,8 +336,8 @@ func (bs *BasicStatus) marshalJSON() *rawStatus {
ProjectRoot: bs.ProjectRoot,
Constraint: bs.getConsolidatedConstraint(),
Version: formatVersion(bs.Version),
Revision: formatVersion(bs.Revision),
Latest: bs.getConsolidatedLatest(),
Revision: string(bs.Revision),
Latest: bs.getConsolidatedLatest(longRev),
PackageCount: bs.PackageCount,
}
}
Expand Down

0 comments on commit 4621913

Please sign in to comment.