From 065fa8abbac33c3b335e95a7ff2500ddf1ab3c8c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 3 Jun 2016 08:11:57 -0700 Subject: [PATCH] [script] update license [ci skip] --- .github/osia_update_lic.rb | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/osia_update_lic.rb diff --git a/.github/osia_update_lic.rb b/.github/osia_update_lic.rb new file mode 100644 index 00000000..0f875344 --- /dev/null +++ b/.github/osia_update_lic.rb @@ -0,0 +1,43 @@ +require_relative 'osia_helper' + +require 'octokit' +require 'netrc' + +client = Octokit::Client.new(:netrc => true) + +j = get_json +apps = j['projects'] +updated = [] + +apps.each do |a| + s = a['source'] + if s.nil? + updated.push a + elsif !(s.include? 'github') + updated.push a + else + begin + g = s.gsub('https://github.com/', '') + r = client.repo g, accept: 'application/vnd.github.drax-preview+json' + lic = r[:license][:key] + print lic + print ':' + + a['license'] = lic + puts a['license'] + + updated.push a + rescue => e + a['license'] = 'other' + puts a['license'] + + updated.push a + next + end + end +end + +j['projects'] = updated + +File.open(FILE, 'w') { |f| f.write JSON.pretty_generate(j) } +puts "\nUpdated #{FILE} ⭐️"