bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 1 | require 'rugged' |
| 2 | require 'fileutils' |
| 3 | require 'cgi' |
bigbiff bigbiff | 43606e6 | 2016-09-24 11:10:11 -0400 | [diff] [blame] | 4 | require 'httparty' |
bigbiff bigbiff | 6107610 | 2016-10-11 20:36:31 -0400 | [diff] [blame] | 5 | require 'resolv-replace' |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 6 | |
| 7 | module Jekyll |
| 8 | module GitActivity |
| 9 | |
bigbiff bigbiff | 43606e6 | 2016-09-24 11:10:11 -0400 | [diff] [blame] | 10 | def gitactivity(devicetree) |
| 11 | repo = devicetree.split("/")[4] |
| 12 | puts repo |
| 13 | url = "https://api.github.com/repos/TeamWin/" + repo + "/commits" |
| 14 | token = File.read("/home/jenkins/token").chomp |
| 15 | user = "Teamwin-Gerrit" |
| 16 | auth = {:username=>user, :password=>token} |
| 17 | resp = HTTParty.get(url, :basic_auth=>auth, :headers=>{"User-Agent"=>"twrpme"}) |
| 18 | json = JSON.parse(resp.body) |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 19 | messages = "" |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 20 | messages += "<div class='page-heading'>Changelog:</div><div>" |
| 21 | messages += "<hr/>" |
| 22 | messages += "<ul>" |
bigbiff bigbiff | 43606e6 | 2016-09-24 11:10:11 -0400 | [diff] [blame] | 23 | count = 0 |
| 24 | json.each do |sha| |
| 25 | break if count == 5 |
| 26 | begin |
| 27 | url = "https://api.github.com/repos/TeamWin/" + repo + "/commits?&sha=" + sha["sha"] |
| 28 | resp2 = HTTParty.get(url, :basic_auth=>auth, :headers=>{"User-Agent"=>"twrpme"}) |
| 29 | json2 = JSON.parse(resp2.body) |
| 30 | messages += "<li>" |
| 31 | messages += json2[0]["commit"]["author"]["name"] |
| 32 | messages += "<br/>" |
| 33 | messages += json2[0]["commit"]["author"]["date"].to_s() |
| 34 | messages += "<br/>" |
| 35 | messages += json2[0]["commit"]["message"] |
| 36 | messages += "</li><br/>" |
| 37 | rescue |
| 38 | puts "skipping" |
| 39 | end |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 40 | count = count + 1 |
| 41 | end |
| 42 | messages += "</ul></div>" |
bigbiff bigbiff | 43606e6 | 2016-09-24 11:10:11 -0400 | [diff] [blame] | 43 | #puts messages |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 44 | "#{messages}" |
| 45 | end |
bigbiff bigbiff | 43606e6 | 2016-09-24 11:10:11 -0400 | [diff] [blame] | 46 | end |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 47 | end |
bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 48 | Liquid::Template.register_filter(Jekyll::GitActivity) |