Skip to content

Commit

Permalink
[Fixed] Prefer to use origin over path for govendor
Browse files Browse the repository at this point in the history
[#165137912]
  • Loading branch information
Vikram Yadav authored and Pivotal committed May 17, 2019
1 parent 6934480 commit 31c6041
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/license_finder/package_managers/govendor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def packages_from_json(json_string)
packages_with_no_sha = []

packages.each do |package|
package_path = package['path']
package_path = package['origin'] || package['path']
package_revision = package['revision']

if !package_is_versioned?(package)
Expand Down
17 changes: 17 additions & 0 deletions spec/fixtures/config/govendor_with_origin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"package": [
{
"checksumSHA1": "4Tc07iR3HloUYC4HNT4xc0875WY=",
"origin": "foo/Bowery/prompt/origin",
"path": "foo/Bowery/prompt",
"revision": "0f1139e9a1c74b57ccce6bdb3cd2f7cd04dd3449",
"revisionTime": "2017-02-19T07:16:37Z"
},
{
"checksumSHA1": "6VGFARaK8zd23IAiDf7a+gglC8k=",
"path": "foo/dchest/safefile",
"revision": "855e8d98f1852d48dde521e0522408d1fe7e836a",
"revisionTime": "2015-10-22T12:31:44+02:00"
}
]
}
25 changes: 25 additions & 0 deletions spec/lib/license_finder/package_managers/govendor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@ module LicenseFinder
expect(subject.current_packages[1].version).to eq ''
end
end

context 'when origin is defined for a package' do
let(:content) do
FakeFS.without do
fixture_from('govendor_with_origin.json')
end
end

before do
FakeFS.activate!
FileUtils.mkdir_p '/app/vendor'
File.write('/app/vendor/vendor.json', content)
end

after do
FakeFS.deactivate!
end

it 'uses origin as path' do
expect(subject.current_packages.length).to eq 2

expect(subject.current_packages[0].name).to eq 'foo/Bowery/prompt/origin'
expect(subject.current_packages[1].name).to eq 'foo/dchest/safefile'
end
end
end

describe '.prepare_command' do
Expand Down

0 comments on commit 31c6041

Please sign in to comment.