benschwarz-gitnotify 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gitnotify +9 -0
- data/lib/gitnotify.rb +77 -0
- data/supports/post-commit +3 -0
- metadata +56 -0
data/bin/gitnotify
ADDED
data/lib/gitnotify.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
class GitNotify
|
3
|
+
|
4
|
+
def self.run(*args)
|
5
|
+
case args.shift
|
6
|
+
when "enable-hook"
|
7
|
+
enable_notify
|
8
|
+
when "disable-hook"
|
9
|
+
disable_notify
|
10
|
+
else
|
11
|
+
help
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def self.enable_notify
|
17
|
+
exit_with! "You're not within a git repository" unless git_repo?
|
18
|
+
FileUtils.touch post_commit
|
19
|
+
FileUtils.chmod 0775, post_commit
|
20
|
+
unless applied_hook?
|
21
|
+
File.open(post_commit, "w+") do |f|
|
22
|
+
f << File.read(post_commit_script)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
puts "Gitnotify: Enabled post-commit"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.disable_notify
|
29
|
+
FileUtils.chmod 0664, post_commit
|
30
|
+
puts "Gitnotify: Disabled post-commit"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.help
|
34
|
+
puts <<-END
|
35
|
+
|
36
|
+
=========================
|
37
|
+
Gitnotify, railscamp love
|
38
|
+
=========================
|
39
|
+
|
40
|
+
Tell your peeps about your commits using growl
|
41
|
+
|
42
|
+
Usage: (from within a git repo): gitnotify <command>
|
43
|
+
|
44
|
+
enable-hook
|
45
|
+
Enables a post-commit hook
|
46
|
+
|
47
|
+
disable-hook
|
48
|
+
Disables a post-commit hook
|
49
|
+
END
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.git_repo?
|
53
|
+
File.exists?(repo_path)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.applied_hook?
|
57
|
+
File.read(post_commit).include?('growlnotify')
|
58
|
+
end
|
59
|
+
|
60
|
+
# Just a standard helper
|
61
|
+
def self.repo_path
|
62
|
+
File.join(Dir.pwd, ".git")
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.post_commit
|
66
|
+
File.join(repo_path, "hooks", "post-commit")
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.post_commit_script
|
70
|
+
File.join(File.dirname(__FILE__), "..", "supports", "post-commit")
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.exit_with!(message)
|
74
|
+
STDERR.puts message
|
75
|
+
exit!
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: benschwarz-gitnotify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Schwarz
|
8
|
+
- Tim Lucas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-09-25 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Tell all your jour peeps about your commits
|
18
|
+
email:
|
19
|
+
executables:
|
20
|
+
- gitnotify
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- bin/gitnotify
|
27
|
+
- lib/gitnotify.rb
|
28
|
+
- supports/post-commit
|
29
|
+
has_rdoc: false
|
30
|
+
homepage: http://git.railscamp.net/projects/gitnotify/
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.2.0
|
52
|
+
signing_key:
|
53
|
+
specification_version: 2
|
54
|
+
summary: Tell all your jour peeps about your commits
|
55
|
+
test_files: []
|
56
|
+
|