bigbiff bigbiff | a5f9f6b | 2016-06-26 20:53:19 -0400 | [diff] [blame] | 1 | require 'rugged' |
| 2 | require 'fileutils' |
| 3 | require 'cgi' |
| 4 | |
| 5 | module 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 |
| 34 | end |
| 35 | |
| 36 | Liquid::Template.register_filter(Jekyll::GitActivity) |