Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Created November 8, 2008 04:05
Show Gist options
  • Save cwsaylor/23022 to your computer and use it in GitHub Desktop.
Save cwsaylor/23022 to your computer and use it in GitHub Desktop.
## ~/bin/hg-growl.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby-growl'
require 'fileutils'
include FileUtils
config = ARGV[0] || "#{ENV['HOME']}/.hg-growl"
if File.exist? config
reposes = IO.readlines(config)
g = Growl.new "localhost", "hg-growl", ["hg-growl Notification"]
reposes.each do |r|
project = File.basename(r).chomp
r = r.strip
next if r.empty?
repos = File.expand_path(r)
next unless File.exist?(repos)
cd(repos) do
response = `hg incoming --template "{author}::::{desc}****"`
line1, line2, commits = response.split("\n")
commits.split("****").each do |c|
author, description = c.split("::::")
# puts "#{author}, #{description}"
g.notify("hg-growl Notification", author.to_s, "[#{project}] #{description.to_s}")
end unless response.include?("no changes found")
end
end
end
## ~/.hg-growl
~/path/to/hg/project
~/path/to/hg/project2
## crontab
SHELL=/bin/bash
HOME=/Users/YOU
PATH=/Users/YOU/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
*/15 * * * * /usr/bin/ruby /Users/YOU/bin/hg-growl.rb > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment