From 7ed3aa220febcec2e36b9c40d0cbe9fbed862aad Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 10 Jan 2018 00:25:03 +0530 Subject: [PATCH] status: LATEST should be of the same type as VERSION This change modifies the LATEST field in status from always being a revision to the same type as of the VERSION field. If VERSION is a semver version, the LATEST would have the latest semver version of the project constrained by the effective constraint. If VERSION is a branch version, the LATEST would have the latest revision of that branch. --- CHANGELOG.md | 1 + cmd/dep/status.go | 7 ++++++- .../testdata/harness_tests/status/case1/json/stdout.txt | 2 +- .../testdata/harness_tests/status/case1/table/stdout.txt | 6 +++--- .../harness_tests/status/override_constraint/stdout.txt | 6 +++--- .../harness_tests/status/revision_constraint/stdout.txt | 6 +++--- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3efaf7fe..831f488d0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ IMPROVEMENTS: * Skip empty constraints during import ([#1414](https://github.com/golang/dep/pull/1349)) * Handle errors when writing status output ([#1420](https://github.com/golang/dep/pull/1420)) * Add constraint for locked projects in `status`. (#962) +* Show LATEST and VERSION as the same type in status. (#1515) # v0.3.2 diff --git a/cmd/dep/status.go b/cmd/dep/status.go index c26b86b7bf..1a24696cc6 100644 --- a/cmd/dep/status.go +++ b/cmd/dep/status.go @@ -570,7 +570,12 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana // upgrade, the first version we encounter that // matches our constraint will be what we want. if c.Constraint.Matches(v) { - bs.Latest = v.Revision() + // Latest should be of the same type as the Version. + if bs.Version.Type() == gps.IsSemver { + bs.Latest = v + } else { + bs.Latest = v.Revision() + } break } } diff --git a/cmd/dep/testdata/harness_tests/status/case1/json/stdout.txt b/cmd/dep/testdata/harness_tests/status/case1/json/stdout.txt index 381f3246d5..3b907c18a1 100644 --- a/cmd/dep/testdata/harness_tests/status/case1/json/stdout.txt +++ b/cmd/dep/testdata/harness_tests/status/case1/json/stdout.txt @@ -1 +1 @@ -[{"ProjectRoot":"github.com/sdboyer/deptest","Constraint":"^0.8.0","Version":"v0.8.0","Revision":"ff2948a2ac8f538c4ecd55962e919d1e13e74baf","Latest":"3f4c3bea144e112a69bbe5d8d01c1b09a544253f","PackageCount":1},{"ProjectRoot":"github.com/sdboyer/deptestdos","Constraint":"v2.0.0","Version":"v2.0.0","Revision":"5c607206be5decd28e6263ffffdcee067266015e","Latest":"5c607206be5decd28e6263ffffdcee067266015e","PackageCount":1}] +[{"ProjectRoot":"github.com/sdboyer/deptest","Constraint":"^0.8.0","Version":"v0.8.0","Revision":"ff2948a2ac8f538c4ecd55962e919d1e13e74baf","Latest":"v0.8.1","PackageCount":1},{"ProjectRoot":"github.com/sdboyer/deptestdos","Constraint":"v2.0.0","Version":"v2.0.0","Revision":"5c607206be5decd28e6263ffffdcee067266015e","Latest":"v2.0.0","PackageCount":1}] diff --git a/cmd/dep/testdata/harness_tests/status/case1/table/stdout.txt b/cmd/dep/testdata/harness_tests/status/case1/table/stdout.txt index dbe1b29360..66b4db1843 100644 --- a/cmd/dep/testdata/harness_tests/status/case1/table/stdout.txt +++ b/cmd/dep/testdata/harness_tests/status/case1/table/stdout.txt @@ -1,3 +1,3 @@ -PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED -github.com/sdboyer/deptest ^0.8.0 v0.8.0 ff2948a 3f4c3be 1 -github.com/sdboyer/deptestdos v2.0.0 v2.0.0 5c60720 5c60720 1 +PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED +github.com/sdboyer/deptest ^0.8.0 v0.8.0 ff2948a v0.8.1 1 +github.com/sdboyer/deptestdos v2.0.0 v2.0.0 5c60720 v2.0.0 1 diff --git a/cmd/dep/testdata/harness_tests/status/override_constraint/stdout.txt b/cmd/dep/testdata/harness_tests/status/override_constraint/stdout.txt index 202f122e20..dc9b6946f9 100644 --- a/cmd/dep/testdata/harness_tests/status/override_constraint/stdout.txt +++ b/cmd/dep/testdata/harness_tests/status/override_constraint/stdout.txt @@ -1,3 +1,3 @@ -PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED -github.com/sdboyer/deptest v0.8.1 (override) v0.8.1 3f4c3be 3f4c3be 1 -github.com/sdboyer/deptestdos v2.0.0 v2.0.0 5c60720 5c60720 1 +PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED +github.com/sdboyer/deptest v0.8.1 (override) v0.8.1 3f4c3be v0.8.1 1 +github.com/sdboyer/deptestdos v2.0.0 v2.0.0 5c60720 v2.0.0 1 diff --git a/cmd/dep/testdata/harness_tests/status/revision_constraint/stdout.txt b/cmd/dep/testdata/harness_tests/status/revision_constraint/stdout.txt index 7a63488b05..cd3c384a9c 100644 --- a/cmd/dep/testdata/harness_tests/status/revision_constraint/stdout.txt +++ b/cmd/dep/testdata/harness_tests/status/revision_constraint/stdout.txt @@ -1,3 +1,3 @@ -PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED -github.com/sdboyer/deptest v1.0.0 v1.0.0 ff2948a ff2948a 1 -github.com/sdboyer/deptestdos a0196ba a0196ba 1 +PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED +github.com/sdboyer/deptest v1.0.0 v1.0.0 ff2948a v1.0.0 1 +github.com/sdboyer/deptestdos a0196ba a0196ba 1