Skip to content

Commit 9e3e76f

Browse files
author
Marco Campana
committed
Moved script to bin/ directory and improved documentation
1 parent 1f4d6b2 commit 9e3e76f

File tree

3 files changed

+89
-45
lines changed

3 files changed

+89
-45
lines changed

README.rdoc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
== git-notifier
2+
3+
git-notifier is a gem that allows you to watch one or more git repositories and receive a growl notification when a change is committed
4+
5+
== Usage
6+
7+
Usage: git-notifier start|stop|add|clear|status
8+
9+
Start the notifier:
10+
git-notifier start
11+
12+
Stop the notifier:
13+
git-notifier stop
14+
15+
Add a repository to the watch list:
16+
git-notifier add <repo_uri> <branch>
17+
Example: git-notifier add git@github.com:marcocampana/git-notifier.git master
18+
19+
Remove all watched repositories from the watch list
20+
git-notifier clear
21+
22+
Show all the watched repositories
23+
git-notifier status
24+
25+
== Install
26+
27+
From github:
28+
29+
gem sources -a http://gems.github.com
30+
sudo gem install marcocampana-git-notifier
31+
32+
== Warning
33+
34+
To appear
35+
36+
== Author
37+
38+
Marco Campana <m.campana@gmail.com>
39+
http://xterm.it/blog
40+
41+
== LICENSE:
42+
43+
Released under the same license as Ruby. No Support. No Warranty.
44+
45+
== Copyright
46+
47+
Copyright (c) 2009 Marco Campana. Licensed under the MIT License:
48+
http://www.opensource.org/licenses/mit-license.php
Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,4 @@
11
#!/usr/bin/env ruby
2-
# == Synopsis
3-
# This is a sample description of the application.
4-
# Blah blah blah.
5-
#
6-
# == Usage
7-
# git-notifier start|stop|add|clear|status
8-
#
9-
# Start the notifier:
10-
# git-notifier start
11-
#
12-
# Stop the notifier:
13-
# git-notifier stop
14-
#
15-
# Add a repository to the watch list:
16-
# git-notifier add <repo_uri> <branch>
17-
# Example: git-notifier add git@github.com:marcocampana/git-notifier.git master
18-
#
19-
# Remove all watched repositories from the watch list
20-
# git-notifier clear
21-
#
22-
# Show all the watched repositories
23-
# git-notifier status
24-
#
25-
# == Author
26-
# Marco Campana <m.campana@gmail.com>
27-
# http://xterm.it/blog
28-
#
29-
# == Copyright
30-
# Copyright (c) 2009 Marco Campana. Licensed under the MIT License:
31-
# http://www.opensource.org/licenses/mit-license.php
32-
332
# TODO
343
# 1) Error handling with notifications
354
# 4) check dependencies at startup
@@ -39,13 +8,39 @@
398
require 'daemons'
409
require 'ruby-growl'
4110
require 'digest/sha1'
42-
require 'rdoc/usage'
4311

44-
# TODO remove this
45-
require 'ruby-debug'
12+
def usage
13+
usage = <<END
14+
15+
Usage:
16+
------
17+
18+
git-notifier start|stop|add|clear|status
19+
20+
21+
Examples:
22+
---------
23+
24+
Start the notifier:
25+
git-notifier start
26+
27+
Stop the notifier:
28+
git-notifier stop
29+
30+
Add a repository to the watch list:
31+
git-notifier add <repo_uri> <branch>
32+
Example: git-notifier add git@github.com:marcocampana/git-notifier.git master
33+
34+
Remove all watched repositories from the watch list
35+
git-notifier clear
36+
37+
Show all the watched repositories
38+
git-notifier status
39+
END
40+
end
4641

4742
def add_repo
48-
(RDoc::usage('usage') and return) if ARGV.size < 2
43+
(puts usage and return) if ARGV.size < 2
4944
repo_uri = ARGV[1]
5045
branch = ARGV[2] || 'master'
5146
repo_name = repo_uri.split("/").last
@@ -89,7 +84,7 @@ def status
8984
def available_repos
9085
repos = []
9186
Dir.new('/var/tmp').each do |repo_dir|
92-
repos << repo_dir if repo_dir =~ /^git-notifier/
87+
repos << repo_dir if repo_dir =~ /^git-notifier_/
9388
end
9489
repos
9590
end
@@ -104,7 +99,7 @@ def clear_all
10499
end
105100

106101
def demonize
107-
Daemons.run_proc('git-notifier', :dir_mode => :normal, :dir => 'pids/', :monitor => false) do
102+
Daemons.run_proc('git-notifier', :dir_mode => :normal, :dir => '/var/tmp/', :monitor => false) do
108103
g = Growl.new "localhost", "ruby-growl", ["git-notifier"]
109104
# g.notify "git-notifier", "GIT Notifier", "Start watching\nrepo: #{ARGV[0]}\nbranch: #{@@branch}"
110105
g.notify "git-notifier", "GIT Notifier", "Start notifier"
@@ -113,7 +108,7 @@ def demonize
113108
# TODO store available_repoes in a variable if adding while running doesn't work
114109
available_repos.each do |repo_dirname|
115110
prefix, repo_sha1, repo_name, repo_branch = repo_dirname.split('_')
116-
111+
117112
git_pull_output = `cd /var/tmp/#{repo_dirname}; git checkout -b #{repo_branch} >/dev/null 2>&1; git pull origin #{repo_branch} 2>/dev/null`
118113

119114
if git_pull_output =~ /Updating (.+)\.\.(.+)/
@@ -150,6 +145,6 @@ def demonize
150145
when 'status'
151146
status
152147
else
153-
RDoc::usage('usage')
148+
puts usage
154149
end
155150

git-notifier.gemspec

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ Gem::Specification.new do |s|
99
s.date = %q{2009-10-13}
1010
s.description = %q{ git-notifier is a gem that allows you to watch one or more git repositories and receive a growl notification when a change is committed}
1111
s.email = %q{m.campana@gmail.com}
12-
s.has_rdoc = true
12+
s.executables = ["git-notifier"]
1313
s.homepage = %q{http://github.com/marcocampana/git-notifier}
14-
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
15-
s.require_paths = ["lib"]
16-
# s.rubyforge_project = %q{git-notifier}
17-
# s.rubygems_version = %q{1.3.3}
18-
# s.summary = %q{ SUMMARY HERE }
14+
# s.has_rdoc = false
15+
# s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
16+
# s.require_paths = ["lib"]
17+
s.rubyforge_project = %q{git-notifier}
18+
s.rubygems_version = %q{1.3.1}
19+
s.summary = %q{ git-notifier is a gem that allows you to watch one or more git repositories and receive a growl notification when a change is committed }
1920

2021
# if s.respond_to? :specification_version then
2122
# current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION

0 commit comments

Comments
 (0)