organization_license_audit 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14a8ff97904b324543f7cb11217c164dd0deb7b0
4
- data.tar.gz: 2b988a0e00bd2ad81febc27665a6762e2a5b952d
3
+ metadata.gz: eee0452f115cdbe368c067b71c9037df3a1df35e
4
+ data.tar.gz: b322f2e530c1d223a02e986b286123cc9a482d3d
5
5
  SHA512:
6
- metadata.gz: 856767681e8befa89e37d27bb7cd2eaa3a6faf99f25f38b2d369f6c8a7407774fa6bb1b62ae2bb311bdca7ba74ffd39a32dc72730c86e81652e86aed9767ed10
7
- data.tar.gz: 75602c0aaf489633a374c4631132e8cf3ea48171385bb0cd21762149fd8aa01e61ac6cb1dc15f481f472616284ef536134e4ced6efe7add1d23f2c337199909e
6
+ metadata.gz: b9c44a552c07566ac0955449668e063848d1134bed3b0f02f21ee0f7922d1b107e2c6b775b26b6ecbf1aa89df89a3a03090c755503aac0b34a43c66076fbea5f
7
+ data.tar.gz: c367e37bec7258f79f3dc90eb606308ada3b1b9509b3c87499d4529cb8564a08a7a3e0a7cae72bd25dc90d9532af90731dd9ff339d19b2f547db07d8bf2c4a34
@@ -1,2 +1,2 @@
1
- �j�� #�zn��sW��V_��)$�{��;�R<����,ZA�����k���e8a���̆�<��'��J�ž�Vt�h�S!��ρ*1iՊN/�Pȧ(�(�g�瞾6Ipߦ�I ���9!;��% lvI��]#�dPů.���#3HH�.�)#4��
2
- LѲ!u$�k�|jT������!09]`y��1:��%AYlr���6�RV#YJ���X?_��`�ϔƕ �C�i�������u��
1
+ aL \�LL�����{��P��V�� qeK�<.�����(,��$���;d'��.���.iK�d[*L3x-�pF�0 ��#����~��:���"a��d o/���5��tt���ᒵ���uҒ Z ��{���DIl����Z���gnMe-�"�X桅���KSa]" I,��Bо�ͻ��F
2
+ Ha-�'�H���oMMI[u!�;-����[Dս�ǶN)�ϛxvwNs �+�%
data.tar.gz.sig CHANGED
Binary file
@@ -13,7 +13,8 @@ end
13
13
  options = {
14
14
  :ignore => [],
15
15
  :user => git_config("github.user"),
16
- :whitelist => []
16
+ :whitelist => [],
17
+ :approve => [],
17
18
  }
18
19
  OptionParser.new do |parser|
19
20
  parser.banner = <<BANNER
@@ -31,9 +32,10 @@ BANNER
31
32
  options[:csv] = separator
32
33
  end
33
34
  parser.on("--ignore-gems", "Ignore repos that have a %{repo}.gemspec") { options[:ignore_gems] = true }
34
- parser.on("--debug REPO", String, "Only run on this repo for fast debugging") { |repo| options[:debug] = repo }
35
+ parser.on("--debug REPO", String, "Only run on this repo for fast debugging") { |repo| options[:debug] = repo.split(",") }
35
36
  parser.on("--without TYPES", String, "Do not run for bundler/npm dependencies (comma separated)") { |without| options[:without] = without.split(",") }
36
- parser.on("-w", "--whitelist=LICENSES", String, "Comma separated list of licenses") { |whitelist| options[:whitelist] = whitelist.split(",") }
37
+ parser.on("-w", "--whitelist LICENSES", String, "Comma separated list of licenses") { |whitelist| options[:whitelist] = whitelist.split(",") }
38
+ parser.on("-a", "--approve DEPENDENCIES", String, "Comma separated list of dependencies to approve") { |approve| options[:approve] = approve.split(",") }
37
39
  parser.on("-h", "--help", "Show this.") { puts parser; exit }
38
40
  parser.on("-v", "--version", "Show Version"){ puts OrganizationLicenseAudit::VERSION; exit}
39
41
  end.parse!
@@ -64,7 +64,7 @@ module OrganizationLicenseAudit
64
64
  end
65
65
 
66
66
  def extract_error(output)
67
- if output.include?(APPROVAL_HEADING)
67
+ if output.to_s.include?(APPROVAL_HEADING)
68
68
  output = output.split("\n")
69
69
  output.reject! { |l| l.include?(APPROVAL_HEADING) || l.strip == "" }
70
70
  output.map do |line|
@@ -86,7 +86,7 @@ module OrganizationLicenseAudit
86
86
  def find_bad(options)
87
87
  Dir.mktmpdir do |bundle_cache_dir|
88
88
  repos = OrganizationAudit.all(options)
89
- repos.select! { |r| r.name == options[:debug] } if options[:debug]
89
+ repos.select! { |r| options[:debug].include?(r.name) } if options[:debug]
90
90
  repos.map do |repo|
91
91
  next if options[:ignore_gems] && repo.gem?
92
92
  success, output = audit_repo(repo, bundle_cache_dir, options)
@@ -111,7 +111,8 @@ module OrganizationLicenseAudit
111
111
  rescue Exception => e
112
112
  raise if e.is_a?(Interrupt) # user interrupted
113
113
  $stderr.puts "Error auditing #{repo.name} (#{e})"
114
- true
114
+ puts e.backtrace if options[:debug]
115
+ false
115
116
  end
116
117
 
117
118
  def needed_files(repo, options)
@@ -123,19 +124,44 @@ module OrganizationLicenseAudit
123
124
  supported & list
124
125
  end
125
126
 
126
- def audit_project(bundle_cache_dir, options)
127
+ def audit_project(bundle_cache_dir, options={})
127
128
  with_clean_env do
128
129
  bundled = prepare_bundler bundle_cache_dir, options
129
130
  prepare_npm options
130
131
  prepare_bower options
131
132
  whitelist_licences options[:whitelist]
133
+ approve_dependencies options[:approve]
132
134
 
133
135
  sh "#{combined_gem_path if bundled}license_finder --quiet"
134
136
  end
135
137
  end
136
138
 
139
+ def approve_dependencies(dependencies)
140
+ return unless dependencies and dependencies.any?
141
+
142
+ # do not keep connection to Sequel around or next run fails
143
+ # reproducible with 2 repos --debug repo1,repo2 --approve xxx
144
+ # even disconnect + connect does not help since it never re-runs
145
+ # migrations, and then fails to run migrations properly
146
+ fork do
147
+ require 'license_finder'
148
+ require 'license_finder/tables'
149
+ require 'license_finder/tables/dependency'
150
+ require 'license_finder/tables/license_alias'
151
+ require 'license_finder/tables/approval'
152
+
153
+ dependencies.each do |name|
154
+ dependency = LicenseFinder::Dependency.new(name: name, version: ">=0")
155
+ dependency.license = LicenseFinder::LicenseAlias.create(name: "other")
156
+ dependency.approval = LicenseFinder::Approval.create(:state => true)
157
+ dependency.save
158
+ end
159
+ end
160
+ Process.waitall # wait for fork to finish
161
+ end
162
+
137
163
  def whitelist_licences(licenses)
138
- return if licenses.none?
164
+ return unless licenses and licenses.any?
139
165
  licenses = licenses.map { |l| Shellwords.escape(l) }.join(" ")
140
166
  unless system("license_finder whitelist add #{licenses} >/dev/null")
141
167
  raise "failed to approve #{licenses}"
@@ -1,3 +1,3 @@
1
1
  module OrganizationLicenseAudit
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: organization_license_audit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -29,7 +29,7 @@ cert_chain:
29
29
  y0kCSWmK6D+x/SbfS6r7Ke07MRqziJdB9GuE1+0cIRuFh8EQ+LN6HXCKM5pon/GU
30
30
  ycwMXfl0
31
31
  -----END CERTIFICATE-----
32
- date: 2014-01-21 00:00:00.000000000 Z
32
+ date: 2014-01-30 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: organization_audit
metadata.gz.sig CHANGED
Binary file