githooks 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -1,7 +1,18 @@
1
1
  # Githooks
2
2
 
3
- TODO: Write a gem description
3
+ A framework to manage git hooks with your repository. Codes in *_githooks.rb will be executed by the framework.
4
4
 
5
+ ## Convention
6
+ Githooks will look for files named as filename_githooks.rb in your repository. The typical directory structure with Githooks will look like this,
7
+ ```
8
+ /Your repository
9
+ /lib
10
+ /app
11
+ ...
12
+ /hooks
13
+ example_githooks.rb
14
+ example2_githooks.rb
15
+ ```
5
16
  ## Installation
6
17
 
7
18
  Add this line to your application's Gemfile:
@@ -18,8 +29,40 @@ Or install it yourself as:
18
29
 
19
30
  ## Usage
20
31
 
21
- TODO: Write usage instructions here
32
+ After the gem is installed, you need to initialize githooks in your repository.
22
33
 
34
+ $ githooks --init
35
+
36
+ Following key words can be used in your githooks.rb files
37
+ * applypatch_msg
38
+ * pre_applypatch
39
+ * post_applypatch
40
+ * pre_commit
41
+ * prepare_commit_msg
42
+ * commit_msg
43
+ * post_commit
44
+ * pre_rebase
45
+ * post_checkout
46
+ * post_merge
47
+ * pre_receive
48
+ * post_receive
49
+ * update
50
+ * post_update
51
+ * pre_auto_gc
52
+ * post_rewrite
53
+
54
+ ## Example
55
+ ```ruby
56
+ # dummy_githooks.rb
57
+ pre_commit do
58
+ puts "executed in pre commit hook"
59
+ end
60
+
61
+ commit_msg do
62
+ puts "executed in commit msg hook"
63
+ exit -1
64
+ end
65
+ ```
23
66
  ## Contributing
24
67
 
25
68
  1. Fork it
data/bin/githooks CHANGED
@@ -21,11 +21,14 @@ options = OptionParser.new do |opts|
21
21
  opts.separator ''
22
22
  opts.separator 'Options:'
23
23
 
24
- opts.on('-i', '--install', 'Install githooks for the current project') do
24
+ opts.on('-i', '--init', 'Initialize githooks for the current repository') do
25
25
  exit unless system("git rev-parse")
26
+ puts "Copying git hooks..."
26
27
  git_root = `git rev-parse --show-toplevel`.chop
27
28
  gem_root = File.expand_path "..", File.dirname($0)
28
29
  FileUtils.cp_r(Dir["#{gem_root}/gems/githooks-#{Githooks::VERSION}/lib/hooks/*"], "#{git_root}/.git/hooks")
30
+ puts "git hooks initialized"
31
+ exit
29
32
  end
30
33
 
31
34
  opts.on( '-l', '--list', 'List supported git hooks') do
data/lib/githooks/base.rb CHANGED
@@ -20,6 +20,11 @@ module Githooks
20
20
  pre_auto_gc
21
21
  post_rewrite]
22
22
  class Base
23
+
24
+ def initialize(args = nil)
25
+ @args = args
26
+ end
27
+
23
28
  def execute
24
29
  lambda {
25
30
  hooks = []
@@ -44,9 +49,10 @@ module Githooks
44
49
  load file
45
50
  end
46
51
 
47
- env = Object.new
52
+ # env = Object.new
48
53
  each_hook do |hook|
49
- env.instance_eval &hook
54
+ # env.instance_eval &hook
55
+ hook.call @args
50
56
  end
51
57
  end
52
58
 
@@ -1,3 +1,3 @@
1
1
  module Githooks
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class ApplypatchMsg < Githooks::Base
6
6
  end
7
7
 
8
- ApplypatchMsg.new.execute
8
+ ApplypatchMsg.new(ARGV).execute
data/lib/hooks/commit-msg CHANGED
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class CommitMsg < Githooks::Base
6
6
  end
7
7
 
8
- CommitMsg.new.execute
8
+ CommitMsg.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostApplypatch < Githooks::Base
6
6
  end
7
7
 
8
- PostApplypatch.new.execute
8
+ PostApplypatch.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostCheckout < Githooks::Base
6
6
  end
7
7
 
8
- PostCheckout.new.execute
8
+ PostCheckout.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostCommit < Githooks::Base
6
6
  end
7
7
 
8
- PostCommit.new.execute
8
+ PostCommit.new(ARGV).execute
data/lib/hooks/post-merge CHANGED
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostMerge < Githooks::Base
6
6
  end
7
7
 
8
- PostMerge.new.execute
8
+ PostMerge.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostReceive < Githooks::Base
6
6
  end
7
7
 
8
- PostReceive.new.execute
8
+ PostReceive.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostRewrite < Githooks::Base
6
6
  end
7
7
 
8
- PostRewrite.new.execute
8
+ PostRewrite.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PostUpdate < Githooks::Base
6
6
  end
7
7
 
8
- PostUpdate.new.execute
8
+ PostUpdate.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PreApplypatch < Githooks::Base
6
6
  end
7
7
 
8
- PreApplypatch.new.execute
8
+ PreApplypatch.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PreAutoGc < Githooks::Base
6
6
  end
7
7
 
8
- PreAutoGc.new.execute
8
+ PreAutoGc.new(ARGV).execute
data/lib/hooks/pre-commit CHANGED
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PreCommit < Githooks::Base
6
6
  end
7
7
 
8
- PreCommit.new.execute
8
+ PreCommit.new(ARGV).execute
data/lib/hooks/pre-rebase CHANGED
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PreRebase < Githooks::Base
6
6
  end
7
7
 
8
- PreRebase.new.execute
8
+ PreRebase.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PreReceive < Githooks::Base
6
6
  end
7
7
 
8
- PreReceive.new.execute
8
+ PreReceive.new(ARGV).execute
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class PrepareCommitMsg < Githooks::Base
6
6
  end
7
7
 
8
- PrepareCommitMsg.new.execute
8
+ PrepareCommitMsg.new(ARGV).execute
data/lib/hooks/update CHANGED
@@ -5,4 +5,4 @@ require 'githooks'
5
5
  class Update < Githooks::Base
6
6
  end
7
7
 
8
- Update.new.execute
8
+ Update.new(ARGV).execute
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: