blob: a7e6dbd67d92a9c63b35450731b020e7cf18eb28 [file] [log] [blame]
bigbiff bigbiffa5f9f6b2016-06-26 20:53:19 -04001require 'rugged'
2require 'fileutils'
3require 'cgi'
4
5module Jekyll
6 module GitActivity
7
8 def gitactivity(github)
9 changelogCount = 5
10 begin
11 repo = Rugged::Repository.clone_at(github, '/tmp/gittemp', {bare: true})
12 rescue
13 return
14 end
15 walker = Rugged::Walker.new(repo)
16 walker.sorting(Rugged::SORT_DATE | Rugged::SORT_TOPO)
17 walker.push(repo.head.target);
18 puts github
19 messages = ""
20 count = 0
21 messages += "<div class='page-heading'>Changelog:</div><div>"
22 messages += "<hr/>"
23 messages += "<ul>"
24 walker.each do |commit|
25 break if count >= changelogCount
26 messages += "<li>" + commit.author[:name] + "<br/>" + commit.author[:time].to_s() + "<br/>" + commit.message + "</li><br/>"
27 count = count + 1
28 end
29 messages += "</ul></div>"
30 FileUtils.rm_rf('/tmp/gittemp')
31 "#{messages}"
32 end
33 end
34end
35
36Liquid::Template.register_filter(Jekyll::GitActivity)