blob: d4a62c38b904517dcda3c170d66a46dad50e9d41 [file] [log] [blame]
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -04001require 'rugged'
2require 'fileutils'
3require 'cgi'
bigbiff bigbiff43606e62016-09-24 11:10:11 -04004require 'httparty'
bigbiff bigbiff61076102016-10-11 20:36:31 -04005require 'resolv-replace'
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -04006
7module Jekyll
8 module GitActivity
9
bigbiff bigbiff43606e62016-09-24 11:10:11 -040010 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 bigbiffa5f9f6b2016-06-26 20:53:19 -040019 messages = ""
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -040020 messages += "<div class='page-heading'>Changelog:</div><div>"
21 messages += "<hr/>"
22 messages += "<ul>"
bigbiff bigbiff43606e62016-09-24 11:10:11 -040023 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 bigbiffa5f9f6b2016-06-26 20:53:19 -040040 count = count + 1
41 end
42 messages += "</ul></div>"
bigbiff bigbiff43606e62016-09-24 11:10:11 -040043 #puts messages
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -040044 "#{messages}"
45 end
bigbiff bigbiff43606e62016-09-24 11:10:11 -040046 end
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -040047end
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -040048Liquid::Template.register_filter(Jekyll::GitActivity)