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

Commit 4621913

Browse files
committed
fix(status): add shortRev and longRev for latest
Adds options to specify shortRev or longRev to getConsolidatedLatest().
1 parent e21b71f commit 4621913

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cmd/dep/status.go

+15-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ print an extended status output for each dependency of the project.
4343
Status returns exit code zero if all dependencies are in a "good state".
4444
`
4545

46+
const (
47+
shortRev = iota
48+
longRev = iota
49+
)
50+
4651
var (
4752
errFailedUpdate = errors.New("failed to fetch updates")
4853
errFailedListPkg = errors.New("failed to list packages")
@@ -104,7 +109,7 @@ func (out *tableOutput) BasicLine(bs *BasicStatus) {
104109
bs.getConsolidatedConstraint(),
105110
formatVersion(bs.Version),
106111
formatVersion(bs.Revision),
107-
bs.getConsolidatedLatest(),
112+
bs.getConsolidatedLatest(shortRev),
108113
bs.PackageCount,
109114
)
110115
}
@@ -308,10 +313,15 @@ func (bs *BasicStatus) getConsolidatedVersion() string {
308313
return version
309314
}
310315

311-
func (bs *BasicStatus) getConsolidatedLatest() string {
316+
func (bs *BasicStatus) getConsolidatedLatest(revSize int) string {
312317
latest := ""
313318
if bs.Latest != nil {
314-
latest = formatVersion(bs.Latest)
319+
switch revSize {
320+
case shortRev:
321+
latest = formatVersion(bs.Latest)
322+
case longRev:
323+
latest = bs.Latest.String()
324+
}
315325
}
316326

317327
if bs.hasError {
@@ -326,8 +336,8 @@ func (bs *BasicStatus) marshalJSON() *rawStatus {
326336
ProjectRoot: bs.ProjectRoot,
327337
Constraint: bs.getConsolidatedConstraint(),
328338
Version: formatVersion(bs.Version),
329-
Revision: formatVersion(bs.Revision),
330-
Latest: bs.getConsolidatedLatest(),
339+
Revision: string(bs.Revision),
340+
Latest: bs.getConsolidatedLatest(longRev),
331341
PackageCount: bs.PackageCount,
332342
}
333343
}

0 commit comments

Comments
 (0)