summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-03-30 23:05:42 -0600
committermo khan <mo.khan@gmail.com>2020-04-02 00:08:43 -0600
commitbfd7459419921ff37ee500f0698862eea6788675 (patch)
tree9749333a7c8878b833b4642afe3071cf1c14012c /lib
parent43bcbbd04342faa497725c5b0be3c6d944d850da (diff)
Reproduce failure with go modules scanning
* Install sudo for existing configurations * Detect dependencies in a gomodules project * Add CHANGELOG entry and bump version * Symlink to $GOPATH for non go modules projects * Remove problematic go get setup
Diffstat (limited to 'lib')
-rw-r--r--lib/license/finder/ext.rb1
-rw-r--r--lib/license/finder/ext/go_modules.rb36
-rw-r--r--lib/license/finder/ext/pip.rb2
-rw-r--r--lib/license/management/version.rb2
4 files changed, 39 insertions, 2 deletions
diff --git a/lib/license/finder/ext.rb b/lib/license/finder/ext.rb
index fffa1c7..24afd37 100644
--- a/lib/license/finder/ext.rb
+++ b/lib/license/finder/ext.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+require 'license/finder/ext/go_modules'
require 'license/finder/ext/license'
require 'license/finder/ext/maven'
require 'license/finder/ext/nuget'
diff --git a/lib/license/finder/ext/go_modules.rb b/lib/license/finder/ext/go_modules.rb
new file mode 100644
index 0000000..2ef3aa2
--- /dev/null
+++ b/lib/license/finder/ext/go_modules.rb
@@ -0,0 +1,36 @@
+module LicenseFinder
+ class GoModules
+ def prepare
+ shell.execute([:go, :mod, :tidy, '-v', '&&', :go, :mod, :vendor, '-v'])
+ end
+
+ def active?
+ Dir[project_path.join('go.sum')].any?
+ end
+
+ def current_packages
+ stdout, _stderr, status = shell.execute([
+ :go, :list, '-m', '-mod=vendor',
+ '-f', "'{{.Path}},{{.Version}},{{.Dir}}'", :all
+ ])
+ return [] unless status.success?
+
+ stdout.lines.map do |line|
+ name, version, dir = line.chomp.split(',')
+ next if Pathname(dir).cleanpath == absolute_project_path
+
+ Package.new(name, version, install_path: dir)
+ end.compact
+ end
+
+ private
+
+ def shell
+ @shell ||= ::License::Management::Shell.new
+ end
+
+ def absolute_project_path
+ @absolute_project_path ||= Pathname(project_path).cleanpath
+ end
+ end
+end
diff --git a/lib/license/finder/ext/pip.rb b/lib/license/finder/ext/pip.rb
index b57d7c8..a55dba7 100644
--- a/lib/license/finder/ext/pip.rb
+++ b/lib/license/finder/ext/pip.rb
@@ -66,7 +66,7 @@ module LicenseFinder
end
def legacy_results
- pip_output.map do |name, version, children, location|
+ pip_output.map do |name, version, _children, _location|
spec = pypi.definition_for(name, version)
Package.new(
name,
diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb
index cee6d57..8440136 100644
--- a/lib/license/management/version.rb
+++ b/lib/license/management/version.rb
@@ -2,6 +2,6 @@
module License
module Management
- VERSION = '3.4.0'
+ VERSION = '3.5.0'
end
end