Skip to content

Instantly share code, notes, and snippets.

@chrismdp
Last active November 9, 2015 14:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismdp/11246067 to your computer and use it in GitHub Desktop.
Save chrismdp/11246067 to your computer and use it in GitHub Desktop.
Use this little script to serve an Atom feed about your git repo. I use it to show a rolling ticker on my Twitch.TV live dev streaming channel. See it in action here: http://twitch.tv/chrismdp_
#!/usr/bin/env ruby
require 'builder'
require 'sinatra'
require 'action_view'
include ActionView::Helpers::DateHelper
get '/' do
date = Time.parse(`git show -s --format=%ci`.chomp)
xml = Builder::XmlMarkup.new
xml.instruct! :xml, :version => '1.1'
xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do
xml.title "Git info"
xml.link "http://localhost"
xml.updated Time.now
xml.id "http://soltrader.net/forums"
xml.entry do
xml.id "Last commit"
xml.title "Last commit: #{`git show -s --format=%s`.chomp} (#{time_ago_in_words(date)} ago)"
end
xml.entry do
xml.id "Changes"
xml.title "Since last commit: #{`git diff HEAD --shortstat`.chomp}"
end
if (File.exist?("MESSAGES"))
File.read("MESSAGES").lines.each_with_index do |line,i|
xml.entry do
xml.id "MSG#{i}"
xml.title line
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment