licensed 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +8 -2
- data/CHANGELOG.md +9 -1
- data/README.md +9 -9
- data/docs/sources/pip.md +1 -0
- data/lib/licensed/cli.rb +5 -0
- data/lib/licensed/source/go.rb +95 -47
- data/lib/licensed/version.rb +1 -1
- data/script/source-setup/go +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87be3d9de274a4f66698f8880f5c858c2733c35f
|
4
|
+
data.tar.gz: eb8125c0b348a042e814bf72732e1fbdce0e4426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53376c057796cd662142d49b5122101d70d6ffc759f945d2da2d26ef0c72f403e5b07a92c8d367aecfcd1f0efa4706a893035d6f9671cb3bddaa948707b05b1b
|
7
|
+
data.tar.gz: ceff661d0fdfda3bfb0920cf246cce9220a13c7675e1547b8be6c3ae8d9f29bb2e78e5541e56c3af3d388a16b5944adb11324e6191afb19d9c9cf95c8aa7086f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -13,14 +13,20 @@ matrix:
|
|
13
13
|
go: "1.7.x"
|
14
14
|
before_script: ./script/source-setup/go
|
15
15
|
script: ./script/test go
|
16
|
-
env: NAME="go"
|
16
|
+
env: NAME="go 1.7.x"
|
17
17
|
|
18
18
|
# go 1.10 tests
|
19
19
|
- language: go
|
20
20
|
go: "1.10.x"
|
21
21
|
before_script: ./script/source-setup/go
|
22
22
|
script: ./script/test go
|
23
|
-
env: NAME="go"
|
23
|
+
env: NAME="go 1.10.x"
|
24
|
+
|
25
|
+
- language: go
|
26
|
+
go: "1.11.1"
|
27
|
+
before_script: ./script/source-setup/go
|
28
|
+
script: ./script/test go
|
29
|
+
env: NAME="go 1.11.1"
|
24
30
|
|
25
31
|
# dep tests
|
26
32
|
- language: go
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## 1.5.2 - 2018-12-27
|
10
|
+
|
11
|
+
### Changes
|
12
|
+
- Go source added support for Go modules and Golang 1.11+ (https://github.com/github/licensed/pull/113)
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Licensed will have a non-zero exit code when commands fail (:tada: @parkr https://github.com/github/licensed/pull/111)
|
16
|
+
|
9
17
|
## 1.5.1 - 2018-10-30
|
10
18
|
|
11
19
|
### Fixed
|
@@ -104,4 +112,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
104
112
|
|
105
113
|
Initial release :tada:
|
106
114
|
|
107
|
-
[Unreleased]: https://github.com/github/licensed/compare/1.5.
|
115
|
+
[Unreleased]: https://github.com/github/licensed/compare/1.5.2...HEAD
|
data/README.md
CHANGED
@@ -91,16 +91,16 @@ See the [configuration file documentation](./docs/configuration.md) for more det
|
|
91
91
|
|
92
92
|
### Sources
|
93
93
|
|
94
|
-
Dependencies will be automatically detected for
|
95
|
-
1. [Bower](./docs/sources/bower.md)
|
94
|
+
Dependencies will be automatically detected for all of the following sources by default.
|
95
|
+
1. [Bower (bower)](./docs/sources/bower.md)
|
96
96
|
2. [Bundler (rubygem)](./docs/sources/bundler.md)
|
97
|
-
3. [Cabal](./docs/sources/cabal.md)
|
98
|
-
4. [Go](./docs/sources/go.md)
|
99
|
-
5. [Go Dep](./docs/sources/dep.md)
|
100
|
-
6. [Manifest lists](./docs/sources/manifests.md)
|
101
|
-
7. [NPM](./docs/sources/npm.md)
|
102
|
-
8. [Pip](./docs/sources/pip.md)
|
103
|
-
9. [Git Submodules](./docs/sources/git_submodule.md)
|
97
|
+
3. [Cabal (cabal)](./docs/sources/cabal.md)
|
98
|
+
4. [Go (go)](./docs/sources/go.md)
|
99
|
+
5. [Go Dep (dep)](./docs/sources/dep.md)
|
100
|
+
6. [Manifest lists (manifests)](./docs/sources/manifests.md)
|
101
|
+
7. [NPM (npm)](./docs/sources/npm.md)
|
102
|
+
8. [Pip (pip)](./docs/sources/pip.md)
|
103
|
+
9. [Git Submodules (git_submodule)](./docs/sources/git_submodule.md)
|
104
104
|
|
105
105
|
You can disable any of them in the configuration file:
|
106
106
|
|
data/docs/sources/pip.md
CHANGED
@@ -16,6 +16,7 @@ _note_: `<your_venv_dir>` path should be relative to the repository root or can
|
|
16
16
|
#### virtual_env_dir (Required)
|
17
17
|
|
18
18
|
The `pip` command will be sourced from this directory.
|
19
|
+
You have to add this setting to your licensed configuration file.
|
19
20
|
An example usage of this might look like:
|
20
21
|
```yaml
|
21
22
|
python:
|
data/lib/licensed/cli.rb
CHANGED
data/lib/licensed/source/go.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "json"
|
3
|
-
require "English"
|
4
3
|
require "pathname"
|
5
4
|
|
6
5
|
module Licensed
|
@@ -20,15 +19,8 @@ module Licensed
|
|
20
19
|
|
21
20
|
def dependencies
|
22
21
|
@dependencies ||= with_configured_gopath do
|
23
|
-
packages.map do |
|
24
|
-
|
25
|
-
import_path = non_vendored_import_path(package_name)
|
26
|
-
|
27
|
-
if package.empty?
|
28
|
-
next if @config.ignored?("type" => Go.type, "name" => package_name)
|
29
|
-
raise "couldn't find package for #{import_path}"
|
30
|
-
end
|
31
|
-
|
22
|
+
packages.map do |package|
|
23
|
+
import_path = non_vendored_import_path(package["ImportPath"])
|
32
24
|
package_dir = package["Dir"]
|
33
25
|
Dependency.new(package_dir, {
|
34
26
|
"type" => Go.type,
|
@@ -36,19 +28,88 @@ module Licensed
|
|
36
28
|
"summary" => package["Doc"],
|
37
29
|
"homepage" => homepage(import_path),
|
38
30
|
"search_root" => search_root(package_dir),
|
39
|
-
"version" => package_version(
|
31
|
+
"version" => package_version(package)
|
40
32
|
})
|
41
|
-
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns an array of dependency package import paths
|
38
|
+
def packages
|
39
|
+
dependency_packages = if go_version < Gem::Version.new("1.11.0")
|
40
|
+
root_package_deps
|
41
|
+
else
|
42
|
+
go_list_deps
|
43
|
+
end
|
44
|
+
|
45
|
+
# don't include go std packages
|
46
|
+
# don't include packages under the root project that aren't vendored
|
47
|
+
dependency_packages
|
48
|
+
.reject { |pkg| go_std_package?(pkg) }
|
49
|
+
.reject { |pkg| local_package?(pkg) }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns non-ignored packages found from the root packages "Deps" property
|
53
|
+
def root_package_deps
|
54
|
+
# check for ignored packages to avoid raising errors calling `go list`
|
55
|
+
# when ignored package is not found
|
56
|
+
Array(root_package["Deps"])
|
57
|
+
.reject { |name| @config.ignored?("type" => Go.type, "name" => name) }
|
58
|
+
.map { |name| package_info(name) }
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns the list of dependencies as returned by "go list -json -deps"
|
62
|
+
# available in go 1.11
|
63
|
+
def go_list_deps
|
64
|
+
@go_list_deps ||= begin
|
65
|
+
deps = package_info_command("-deps")
|
66
|
+
# the CLI command returns packages in a pretty-printed JSON format but
|
67
|
+
# not separated by commas. this gsub adds commas after all non-indented
|
68
|
+
# "}" that close root level objects.
|
69
|
+
# (?!\z) uses negative lookahead to not match the final "}"
|
70
|
+
deps.gsub!(/^}(?!\z)$/m, "},")
|
71
|
+
JSON.parse("[#{deps}]")
|
72
|
+
.reject { |pkg| @config.ignored?("type" => Go.type, "name" => pkg["ImportPath"]) }
|
73
|
+
.each { |pkg| raise pkg.dig("Error", "Err") if pkg["Error"] }
|
42
74
|
end
|
43
75
|
end
|
44
76
|
|
45
|
-
# Returns the
|
46
|
-
# not
|
77
|
+
# Returns whether the given package import path belongs to the
|
78
|
+
# go std library or not
|
47
79
|
#
|
48
|
-
#
|
49
|
-
def
|
80
|
+
# package - package to check as part of the go standard library
|
81
|
+
def go_std_package?(package)
|
82
|
+
return false unless package
|
83
|
+
return true if package["Standard"]
|
84
|
+
|
85
|
+
import_path = package["ImportPath"]
|
86
|
+
return false unless import_path
|
87
|
+
|
88
|
+
# modify the import path to look like the import path `go list` returns for vendored std packages
|
89
|
+
std_vendor_import_path = import_path.sub(%r{^#{root_package["ImportPath"]}/vendor/golang.org}, "vendor/golang_org")
|
90
|
+
go_std_packages.include?(import_path) || go_std_packages.include?(std_vendor_import_path)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Returns whether the package is local to the current project
|
94
|
+
def local_package?(package)
|
95
|
+
return false unless package && package["ImportPath"]
|
96
|
+
import_path = package["ImportPath"]
|
97
|
+
import_path.start_with?(root_package["ImportPath"]) && !vendored_path?(import_path)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns the version for a given package
|
101
|
+
#
|
102
|
+
# package - package to get version of
|
103
|
+
def package_version(package)
|
104
|
+
# use module version if it exists
|
105
|
+
go_mod = package["Module"]
|
106
|
+
return go_mod["Version"] if go_mod
|
107
|
+
|
108
|
+
package_directory = package["Dir"]
|
50
109
|
return unless package_directory
|
51
110
|
|
111
|
+
# find most recent git SHA for a package, or nil if SHA is
|
112
|
+
# not available
|
52
113
|
Dir.chdir package_directory do
|
53
114
|
Licensed::Git.version(".")
|
54
115
|
end
|
@@ -64,25 +125,6 @@ module Licensed
|
|
64
125
|
"https://#{import_path}"
|
65
126
|
end
|
66
127
|
|
67
|
-
# Returns an array of dependency package import paths
|
68
|
-
def packages
|
69
|
-
return [] unless root_package["Deps"]
|
70
|
-
|
71
|
-
# don't include go std packages
|
72
|
-
# don't include packages under the root project that aren't vendored
|
73
|
-
root_package["Deps"]
|
74
|
-
.uniq
|
75
|
-
.select { |d| !go_std_packages.include?(d) }
|
76
|
-
.select { |d| !d.start_with?(root_package["ImportPath"]) || vendored_path?(d) }
|
77
|
-
.select do |d|
|
78
|
-
# this removes the packages listed in `go list std` as "vendor/golang_org/*" but are vendored
|
79
|
-
# as "vendor/golang.org/*"
|
80
|
-
go_std_packages.none? do |std_pkg|
|
81
|
-
std_pkg.sub(%r{^vendor/golang_org/}, "#{root_package["ImportPath"]}/vendor/golang.org/") == d
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
128
|
# Returns the root directory to search for a package license
|
87
129
|
#
|
88
130
|
# package - package object obtained from package_info
|
@@ -112,31 +154,28 @@ module Licensed
|
|
112
154
|
import_path.split("vendor/")[1]
|
113
155
|
end
|
114
156
|
|
115
|
-
# Returns
|
157
|
+
# Returns a hash of information about the package with a given import path
|
116
158
|
#
|
117
|
-
#
|
118
|
-
def package_info(
|
119
|
-
|
120
|
-
return {} if info.empty?
|
121
|
-
JSON.parse(info)
|
159
|
+
# import_path - Go package import path
|
160
|
+
def package_info(import_path)
|
161
|
+
JSON.parse(package_info_command(import_path))
|
122
162
|
end
|
123
163
|
|
124
164
|
# Returns package information as a JSON string
|
125
165
|
#
|
126
|
-
#
|
127
|
-
def package_info_command(
|
128
|
-
|
129
|
-
Licensed::Shell.execute("go", "list", "-json", package, allow_failure: true)
|
166
|
+
# args - additional arguments to `go list`, e.g. Go package import path
|
167
|
+
def package_info_command(*args)
|
168
|
+
Licensed::Shell.execute("go", "list", "-json", *Array(args)).strip
|
130
169
|
end
|
131
170
|
|
132
171
|
# Returns the info for the package under test
|
133
172
|
def root_package
|
134
|
-
@root_package ||= package_info
|
173
|
+
@root_package ||= package_info(".")
|
135
174
|
end
|
136
175
|
|
137
176
|
# Returns whether go source is found
|
138
177
|
def go_source?
|
139
|
-
|
178
|
+
with_configured_gopath { Licensed::Shell.success?("go", "doc") }
|
140
179
|
end
|
141
180
|
|
142
181
|
# Returns a list of go standard packages
|
@@ -162,6 +201,15 @@ module Licensed
|
|
162
201
|
end
|
163
202
|
end
|
164
203
|
|
204
|
+
# Returns the current version of go available, as a Gem::Version
|
205
|
+
def go_version
|
206
|
+
@go_version ||= begin
|
207
|
+
full_version = Licensed::Shell.execute("go", "version").strip
|
208
|
+
version_string = full_version.gsub(%r{.*go(\d+\.\d+(\.\d+)?).*}, "\\1")
|
209
|
+
Gem::Version.new(version_string)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
165
213
|
private
|
166
214
|
|
167
215
|
# Execute a block with ENV["GOPATH"] set to the value of #gopath.
|
data/lib/licensed/version.rb
CHANGED
data/script/source-setup/go
CHANGED
@@ -12,8 +12,20 @@ export GOPATH="$BASE_PATH/test/fixtures/go"
|
|
12
12
|
cd $BASE_PATH/test/fixtures/go
|
13
13
|
|
14
14
|
if [ "$1" == "-f" ]; then
|
15
|
-
find . -not -regex "\.*"
|
15
|
+
find . -not -regex "\.*" \
|
16
|
+
-and -not -path "*/src/test*" \
|
17
|
+
-and -not -path "*/src/modules_test*" \
|
18
|
+
-and -not -path "*/pkg/mod*" \
|
19
|
+
-and -not -path "*/pkg" \
|
20
|
+
-and -not -path "*/src" \
|
21
|
+
-print0 | xargs -0 rm -rf
|
22
|
+
|
23
|
+
if go help mod >/dev/null; then
|
24
|
+
go clean -modcache
|
25
|
+
fi
|
16
26
|
fi
|
17
27
|
|
18
|
-
cd src/test
|
19
|
-
go
|
28
|
+
(cd src/test && go get)
|
29
|
+
if go help mod >/dev/null; then
|
30
|
+
(cd src/modules_test && GO111MODULE=on go mod download)
|
31
|
+
fi
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: licensee
|