Skip to content

Commit

Permalink
[fixed] Package manager name for Go modules
Browse files Browse the repository at this point in the history
- it now reads as 'Go'

[finish #161096448]
  • Loading branch information
Manifaust committed Oct 10, 2018
1 parent ffe5754 commit 860de9e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 9 additions & 1 deletion lib/license_finder/package_managers/go_modules.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'license_finder/packages/go_package'

module LicenseFinder
class GoModules < PackageManager
PACKAGES_FILE = 'go.sum'
Expand Down Expand Up @@ -48,7 +50,13 @@ def read_package(file_path, line)
name = parts[0]
version = parts[1]

Package.new(name, version, install_path: install_path)
info = {
'ImportPath' => name,
'InstallPath' => install_path,
'Rev' => version
}

GoPackage.from_dependency(info, nil, true)
end
end
end
2 changes: 2 additions & 0 deletions lib/license_finder/packages/go_package.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'license_finder/package'

module LicenseFinder
class GoPackage < Package
def package_manager
Expand Down
12 changes: 9 additions & 3 deletions spec/lib/license_finder/package_managers/go_modules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ module LicenseFinder
describe '#current_packages' do
before do
FakeFS.activate!

FileUtils.mkdir_p(vendor_path)
File.write(sum_path, content)
end

after do
Expand All @@ -32,9 +35,6 @@ module LicenseFinder
end

it 'finds all the packages all go.sum files' do
FileUtils.mkdir_p(vendor_path)
File.write(sum_path, content)

packages = subject.current_packages

expect(packages.length).to eq 2
Expand All @@ -45,6 +45,12 @@ module LicenseFinder
expect(packages.last.name).to eq 'gopkg.in/yaml.v2'
expect(packages.last.version).to eq 'v2.2.1'
end

it 'list packages as Go packages' do
packages = subject.current_packages

expect(packages.first.package_manager).to eq 'Go'
end
end

describe '.prepare_command' do
Expand Down

0 comments on commit 860de9e

Please sign in to comment.