hooky 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ require "autotest/restart"
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.testlib = "minitest/autorun"
5
+ end
@@ -0,0 +1,3 @@
1
+ === 1.0.0 / 2009-08-20
2
+
3
+ * Birthday!
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ CHANGELOG.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/hooky.rb
7
+ lib/hooky/tasks.rb
8
+ test/test_hooky.rb
@@ -0,0 +1,98 @@
1
+ = Hooky
2
+
3
+ * http://github.com/jbarnette/hooky
4
+ * http://www.kernel.org/pub/software/scm/git/docs/githooks.html
5
+
6
+ == Description
7
+
8
+ Hooky lets you write Git repository hooks with Rake. If you already
9
+ have a Rakefile, write your hooks in Ruby! Hooky provides Tasks for
10
+ most Git hooks, and lets you easily add behavior.
11
+
12
+ Git hooks are powerful: Check the Git documentation (linked above) for
13
+ detailed descriptions and lifecycle order.
14
+
15
+ == Examples
16
+
17
+ # in your Rakefile
18
+ require "hooky/tasks"
19
+
20
+ task "git:applypatch-msg", [:file] do |_, args|
21
+ puts "Proposed git-am commit msg: #{IO.read(args[:file])}"
22
+ end
23
+
24
+ task "git:commit-msg", [:file] do |_, args|
25
+ puts "Proposed commit msg: #{IO.read(args[:file])}"
26
+ end
27
+
28
+ task "git:post-applypatch" do
29
+ puts "Patch applied by git-am!"
30
+ end
31
+
32
+ task "git:post-checkout", [:old, :new, :branch] do |_, args|
33
+ puts "you just switched branches!" if args[:branch]
34
+ puts "old SHA: #{args[:old]}, new SHA: #{args[:new]}"
35
+ end
36
+
37
+ task "git:post-commit"
38
+ puts "You made a commit!"
39
+ end
40
+
41
+ task "git:post-merge", [:squash] do |_, args|
42
+ puts "You just did a merge!"
43
+ puts "It was a squash." if args[:squash]
44
+ end
45
+
46
+ task "git:pre-applypatch" do
47
+ puts "git-am is about to commit a patch!"
48
+ end
49
+
50
+ task "git:pre-auto-gc" do
51
+ puts "git gc --auto is about to run!"
52
+ end
53
+
54
+ task "git:pre-commit" do
55
+ puts "You're about to commit!"
56
+ end
57
+
58
+ task "git:pre-rebase" do
59
+ puts "You're about to rebase!"
60
+ end
61
+
62
+ task "git:prepare-commit-msg", [:file, :source, :sha] do |_, args|
63
+ puts "Building a commit message!"
64
+ end
65
+
66
+ == Installation
67
+
68
+ $ gem install hooky
69
+
70
+ # in your project
71
+ $ rake hooky:install
72
+
73
+ <tt>hooky:install</tt> symlinks all hooks to
74
+ <tt>.git/hooks/hooky</tt>, a stub that delegates to your Rakefile, but
75
+ it won't overwrite any hooks you've already created.
76
+
77
+ == License
78
+
79
+ Copyright 2009 John Barnette (jbarnette@rubyforge.org)
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining
82
+ a copy of this software and associated documentation files (the
83
+ 'Software'), to deal in the Software without restriction, including
84
+ without limitation the rights to use, copy, modify, merge, publish,
85
+ distribute, sublicense, and/or sell copies of the Software, and to
86
+ permit persons to whom the Software is furnished to do so, subject to
87
+ the following conditions:
88
+
89
+ The above copyright notice and this permission notice shall be
90
+ included in all copies or substantial portions of the Software.
91
+
92
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
93
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
95
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
96
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
97
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
98
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ require "rubygems"
2
+ require "hoe"
3
+
4
+ Hoe.plugin :doofus, :git
5
+
6
+ Hoe.spec "hooky" do
7
+ developer "John Barnette", "jbarnette@rubyforge.org"
8
+
9
+ self.extra_rdoc_files = FileList["*.rdoc"]
10
+ self.history_file = "CHANGELOG.rdoc"
11
+ self.readme_file = "README.rdoc"
12
+ self.testlib = :minitest
13
+ end
@@ -0,0 +1,5 @@
1
+ # Git hooks in Rake. See <tt>README.rdoc</tt> for details.
2
+
3
+ class Hooky
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,66 @@
1
+ git_hooks = %w(applypatch-msg commit-msg post-applypatch post-checkout
2
+ post-commit post-merge pre-applypatch pre-auto-gc pre-commit
3
+ pre-rebase prepare-commit-msg)
4
+
5
+ git_hook_files = git_hooks.collect { |f| ".git/hooks/#{f}" }
6
+
7
+ git_hook_files.each do |f|
8
+ file f do |task|
9
+ sh "ln -s hooky #{task.name}"
10
+ end
11
+ end
12
+
13
+ desc "Install magical Rake Git hooks. Nondestructive."
14
+ task "hooky:install" => [".git/hooks/hooky", *git_hook_files]
15
+
16
+ file ".git/hooks/hooky" do |task|
17
+ File.open task.name, "w" do |f|
18
+ f.puts "#!/bin/sh"
19
+ f.puts "export HOOK=$0"
20
+ f.puts "export HOOK_ARGS=$@"
21
+ f.puts "rake -s hooky"
22
+ end
23
+
24
+ sh "chmod +x #{task.name}"
25
+ end
26
+
27
+ # These tasks are intentionally not described in Rake's -T output to
28
+ # avoid clutter. The 'hooky' task dispatches to a specific hook
29
+ # task. To add behavior to a Git hook in your own Rakefile, 'redefine'
30
+ # the appropriate task.
31
+
32
+ task :hooky do
33
+ ENV["HOOK"] && ENV["HOOK_ARGS"] or raise "Need HOOK and HOOK_ARGS."
34
+
35
+ hook = File.basename ENV["HOOK"]
36
+ args = ENV["HOOK_ARGS"].split /\s+/
37
+
38
+ warn({ :hook => hook, :args => args }.inspect) if ENV["DEBUG"]
39
+ Rake::Task["git:#{hook}"].invoke *args
40
+ end
41
+
42
+ task "git:applypatch-msg", [:file]
43
+
44
+ task "git:commit-msg", [:file]
45
+
46
+ task "git:post-applypatch"
47
+
48
+ task "git:post-checkout", [:old, :new, :branch] do |_, args|
49
+ args.to_hash[:branch] = args[:branch] == "1"
50
+ end
51
+
52
+ task "git:post-commit"
53
+
54
+ task "git:post-merge", [:squash] do |_, args|
55
+ args.to_hash[:squash] = args[:squash] == "1"
56
+ end
57
+
58
+ task "git:pre-applypatch"
59
+
60
+ task "git:pre-auto-gc"
61
+
62
+ task "git:pre-commit"
63
+
64
+ task "git:pre-rebase"
65
+
66
+ task "git:prepare-commit-msg", [:file, :source, :sha]
@@ -0,0 +1,8 @@
1
+ require "minitest/autorun"
2
+ require "hooky"
3
+
4
+ class TestHooky < MiniTest::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hooky
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - John Barnette
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ description: |-
26
+ Hooky lets you write Git repository hooks with Rake. If you already
27
+ have a Rakefile, write your hooks in Ruby! Hooky provides Tasks for
28
+ most Git hooks, and lets you easily add behavior.
29
+
30
+ Git hooks are powerful: Check the Git documentation (linked above) for
31
+ detailed descriptions and lifecycle order.
32
+ email:
33
+ - jbarnette@rubyforge.org
34
+ executables: []
35
+
36
+ extensions: []
37
+
38
+ extra_rdoc_files:
39
+ - Manifest.txt
40
+ - CHANGELOG.rdoc
41
+ - README.rdoc
42
+ files:
43
+ - .autotest
44
+ - CHANGELOG.rdoc
45
+ - Manifest.txt
46
+ - README.rdoc
47
+ - Rakefile
48
+ - lib/hooky.rb
49
+ - lib/hooky/tasks.rb
50
+ - test/test_hooky.rb
51
+ has_rdoc: true
52
+ homepage: http://github.com/jbarnette/hooky
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options:
57
+ - --main
58
+ - README.rdoc
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ requirements: []
74
+
75
+ rubyforge_project: hooky
76
+ rubygems_version: 1.3.5
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Hooky lets you write Git repository hooks with Rake
80
+ test_files:
81
+ - test/test_hooky.rb