Resources‎ > ‎Standard Procedures‎ > ‎Git‎ > ‎

Generating RSS Feed

If you are working on a collaborative project, you often would like to keep track on what others done to the project. The following explain how to automatically generate a RSS feed upon someone put new changes into the repository.


First, the following Ruby script will generates a RSS feed file from the git repository.  This script is hosted here

require 'digest/md5'
def git_rss(repository_path, repository_title)
  git_history = `cd #{repository_path} && git log --max-count=20 --name-status`

  entries = git_history.split("\ncommit ")

  rss = """<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0'>

<title>#{repository_title} Git Commits</title>
<description>Git commits to your repository</description>

  entries.each do |entry|
    guid = entry.gsub(/^.*commit /ms, '')
    guid = guid.gsub(/\n.*$/ms, '')
    author_name = entry.gsub(/^.*Author: /ms, '').gsub(/ <.*$/ms, '')
    author_email = entry.gsub(/^.* </ms, '').gsub(/>.*$/ms, '')
    gravatar_hash = Digest::MD5.hexdigest(author_email)
    gravatar = "{gravatar_hash}"
    date = entry.gsub(/^.*Date: +/ms, '').gsub(/\n.*$/ms, '')
    comments = entry.gsub(/^.*Date[^\n]*/ms, '')
    comment_lines = comments.split("\n")
    comment_lines = {|line| line.strip}
    first_line_of_comments = comment_lines.find {|line| line =~ /\S/}
    first_line_of_comments ||= " "
    rss += "
<title>#{first_line_of_comments} - #{author_name}</title>
<description>#{author_name} made a commit on #{date}</description>
<p><a href=''><img src='#{gravatar}'> #{author_email}</a></p>
<guid isPermaLink='false'>#{guid}</guid>

  rss += "

# Command line argument 1: Path to git repository
repository_path = $*[0]
# Command line argument 2: Repository title to be displayed in RSS feed
repository_title = $*[1]
puts git_rss(repository_path, repository_title)

Put this gitrss.rb in /Groups/git folder on (vislab's project server).  Then in each project's git repository, put the following file (post-receive) in hooks folder.
You need to change 


# An example hook script for the "post-receive" event.                          
# The "post-receive" script is run after receive-pack has accepted a pack       
# and the repository has been updated.  It is passed arguments in through       
# stdin in the form                                                             
#  <oldrev> <newrev> <refname>                                                  
# For example:                                                                  
#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b7\
9f814 refs/heads/master                                                         
# see contrib/hooks/ for a sample, or uncomment the next line and               
# rename the file to "post-receive".                                            

#. /usr/share/doc/git-core/contrib/hooks/post-receive-email                     
ruby /Groups/git/gitrss.rb /Groups/GROUPNAME/project_name.git project_name.git > /Library/WebServer/Documents/git_rss/project_name.git.rss

Then, you can subscribe the RSS feed:

or you can put the RSS feed widget on project's home page.