twrpme: add gitactivity changelog tag to device markdowns
Change-Id: I437a42c1b2ccd79b3f85ad0962c362680c28d171
diff --git a/_plugins/gitactivity.rb b/_plugins/gitactivity.rb
new file mode 100644
index 0000000..a7e6dbd
--- /dev/null
+++ b/_plugins/gitactivity.rb
@@ -0,0 +1,36 @@
+require 'rugged'
+require 'fileutils'
+require 'cgi'
+
+module Jekyll
+ module GitActivity
+
+ def gitactivity(github)
+ changelogCount = 5
+ begin
+ repo = Rugged::Repository.clone_at(github, '/tmp/gittemp', {bare: true})
+ rescue
+ return
+ end
+ walker = Rugged::Walker.new(repo)
+ walker.sorting(Rugged::SORT_DATE | Rugged::SORT_TOPO)
+ walker.push(repo.head.target);
+ puts github
+ messages = ""
+ count = 0
+ messages += "<div class='page-heading'>Changelog:</div><div>"
+ messages += "<hr/>"
+ messages += "<ul>"
+ walker.each do |commit|
+ break if count >= changelogCount
+ messages += "<li>" + commit.author[:name] + "<br/>" + commit.author[:time].to_s() + "<br/>" + commit.message + "</li><br/>"
+ count = count + 1
+ end
+ messages += "</ul></div>"
+ FileUtils.rm_rf('/tmp/gittemp')
+ "#{messages}"
+ end
+ end
+end
+
+Liquid::Template.register_filter(Jekyll::GitActivity)