cwsaylor (owner)

Revisions

gist: 23022 Download_button fork
public
Public Clone URL: git://gist.github.com/23022.git
Embed All Files: show embed
Text #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## ~/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