[script] history

This commit is contained in:
Daniel Khamsing 2016-07-27 14:51:37 -07:00 committed by dkhamsing
parent 4ecfe948b0
commit e930431d16
3 changed files with 110 additions and 0 deletions

24
.github/osia_get_history.rb vendored Normal file
View File

@ -0,0 +1,24 @@
require_relative 'osia_helper'
HISTORY = 'git_history'
j = get_json
apps = j['projects']
h = {}
apps.each_with_index do |a, i|
t = a['title']
puts "#{i + 1}/#{apps.count}. checking #{t}"
command = "git log --all --grep='#{t}'"
begin
r = `#{command}`
rescue e
r = e
end
h[t] = r
end
File.open(HISTORY, 'w') { |f| f.write JSON.pretty_generate h }
puts "wrote #{HISTORY}"

12
.github/osia_history_missing.rb vendored Normal file
View File

@ -0,0 +1,12 @@
require_relative 'osia_helper'
j = get_json
apps = j['projects']
i = 0
apps.each do |a|
if a['date_added'].nil?
puts "#{i + 1}. History missing for #{a['title']}"
i = i + 1
end
end

74
.github/osia_update_history.rb vendored Normal file
View File

@ -0,0 +1,74 @@
require_relative 'osia_helper'
require 'awesome_print'
require 'colored'
HISTORY = 'git_history'
def get_author(a)
a = a.gsub 'Author:', ''
u =
if a.include? 'users.noreply.github.com>'
m = /<.*?@/.match a
'@' + m[0].sub('@','')
else
m = /.*</.match a
m[0]
end
t = u.sub('<', '').strip
t
end
j = get_json
apps = j['projects']
updated = []
c = File.read HISTORY
history = JSON.parse c
apps.each_with_index do |a, i|
t = a['title']
puts "#{i + 1}/#{apps.count}. Updating #{t}".yellow
h = history[t]
# TODO: skip entries with history
if h.size==0
updated.push a
else
lines = h.split "\n"
d=''
u=''
lines.reverse.each do |x|
# puts x
if d=='' || u==''
if x.include? 'Date:'
d = x.gsub('Date:','').strip
# d = x.gsub 'Date:',''
# puts d
end
if x.include? 'Author:'
u = get_author(x)
end
end
end
a['date_added'] = d
a['suggested_by'] = u
updated.push a
end
end
j['projects'] = updated
File.open(FILE, 'w') { |f| f.write JSON.pretty_generate(j) }
puts "\nUpdated #{FILE} ⭐️"