Skip to content

Commit

Permalink
fix: govendor: use versionExact if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-go committed Sep 26, 2017
1 parent d7bd885 commit dd81407
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ function parseGovendorLock(root, targetFile) {
var deps = {};
var lockJson = JSON.parse(lock);
lockJson.package && lockJson.package.forEach(function (pkg) {
var version = pkg.versionExact || ('#' + pkg.revision);

var dep = {
name: pkg.path,
version: '#' + pkg.revision,
version: version,
}

deps[dep.name] = dep;
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/gopath/src/path/to/pkg/vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{
"checksumSHA1": "dummy",
"path": "gitpub.com/food/salad",
"revision": "8b100cedd15d96a9ba0f4e48fd852d21b93b0f33"
"revision": "8b100cedd15d96a9ba0f4e48fd852d21b93b0f33",
"versionExact": "v1.3.7"
},
{
"checksumSHA1": "dummy",
Expand All @@ -21,7 +22,8 @@
{
"checksumSHA1": "dummy",
"path": "gitpub.com/meal/dinner",
"revision": "2ebf14b5ac2969032b6c7f6f3e9ff1b2a8db0075"
"revision": "2ebf14b5ac2969032b6c7f6f3e9ff1b2a8db0075",
"versionExact": "v0.0.7"
}
]
}
17 changes: 7 additions & 10 deletions test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ test('happy inspect govendor', function (t) {

t.match(deps['gitpub.com/food/salad'], {
name: 'gitpub.com/food/salad',
version: '#8b100cedd15d96a9ba0f4e48fd852d21b93b0f33',
version: 'v1.3.7',
dependencies: {
'gitpub.com/nature/vegetables/tomato': {
version: '#b6ffb7d62206806b573348160795ea16a00940a6',
Expand All @@ -271,31 +271,28 @@ test('happy inspect govendor', function (t) {
version: '#b6ffb7d62206806b573348160795ea16a00940a6',
},
},
from: [
'path/to/[email protected]',
'gitpub.com/food/salad@#8b100cedd15d96a9ba0f4e48fd852d21b93b0f33',
],
from: ['path/to/[email protected]', 'gitpub.com/food/[email protected]'],
}, 'salad depends on tomato and cucamba');

t.match(deps['gitpub.com/meal/dinner'], {
version: '#2ebf14b5ac2969032b6c7f6f3e9ff1b2a8db0075',
version: 'v0.0.7',
dependencies: {
'gitpub.com/food/salad': {
version: '#8b100cedd15d96a9ba0f4e48fd852d21b93b0f33',
version: 'v1.3.7',
dependencies: {
'gitpub.com/nature/vegetables/tomato': {
version: '#b6ffb7d62206806b573348160795ea16a00940a6',
from: [
'path/to/[email protected]',
'gitpub.com/meal/dinner@#2ebf14b5ac2969032b6c7f6f3e9ff1b2a8db0075', // jscs:ignore maximumLineLength
'gitpub.com/food/salad@#8b100cedd15d96a9ba0f4e48fd852d21b93b0f33', // jscs:ignore maximumLineLength
'gitpub.com/meal/dinner@v0.0.7',
'gitpub.com/food/salad@v1.3.7',
'gitpub.com/nature/vegetables/tomato@#b6ffb7d62206806b573348160795ea16a00940a6', // jscs:ignore maximumLineLength
],
},
},
},
},
}, 'salad is also a trasitive dependency')
}, 'salad is also a trasitive dependency');

t.end();
});
Expand Down

0 comments on commit dd81407

Please sign in to comment.