githooks 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -5
- data/bin/githooks +8 -1
- data/githooks.gemspec +1 -1
- data/lib/githooks/base.rb +3 -4
- data/lib/githooks/version.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
A framework to manage git hooks with your repository. Codes in *_githooks.rb will be executed by the framework.
|
4
4
|
|
5
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,
|
6
|
+
Githooks will look for files named as filename_githooks.rb under githooks folder in your repository. The typical directory structure with Githooks will look like this,
|
7
7
|
```
|
8
8
|
/Your repository
|
9
9
|
/lib
|
10
10
|
/app
|
11
11
|
...
|
12
|
-
/
|
12
|
+
/githooks
|
13
13
|
example_githooks.rb
|
14
14
|
example2_githooks.rb
|
15
15
|
```
|
@@ -87,6 +87,5 @@ The example hook checks whether the commit message follows the provided pattern.
|
|
87
87
|
|
88
88
|
## TODO
|
89
89
|
|
90
|
-
1.
|
91
|
-
2.
|
92
|
-
3. Share context across hooks
|
90
|
+
1. Provide git related information in the environment
|
91
|
+
2. Share context across hooks
|
data/bin/githooks
CHANGED
@@ -28,7 +28,14 @@ options = OptionParser.new do |opts|
|
|
28
28
|
git_root = `git rev-parse --show-toplevel`.chop
|
29
29
|
gem_root = File.expand_path "..", File.dirname($0)
|
30
30
|
FileUtils.cp_r(Dir["#{gem_root}/gems/githooks-#{Githooks::VERSION}/lib/hooks/*"], "#{git_root}/.git/hooks")
|
31
|
-
|
31
|
+
|
32
|
+
puts "Creating githooks directory..."
|
33
|
+
begin
|
34
|
+
FileUtils.mkdir "#{git_root}/githooks", :mode => 0755
|
35
|
+
rescue => e
|
36
|
+
puts "githooks directory is not created, #{e.message}"
|
37
|
+
end
|
38
|
+
puts "Git hooks initialized"
|
32
39
|
end
|
33
40
|
exit
|
34
41
|
end
|
data/githooks.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.authors = ["Yu Zhang"]
|
10
10
|
gem.email = ["ian7zy@gmail.com"]
|
11
11
|
gem.description = %q{A git hooks framework in Ruby}
|
12
|
-
gem.summary = %q{A framework to manage git hooks with your
|
12
|
+
gem.summary = %q{A framework to manage git hooks with your repository}
|
13
13
|
gem.homepage = "https://github.com/ianzy/githooks"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
data/lib/githooks/base.rb
CHANGED
@@ -33,14 +33,13 @@ module Githooks
|
|
33
33
|
def execute
|
34
34
|
git_root = `git rev-parse --show-toplevel`.chop
|
35
35
|
|
36
|
-
Dir.glob("#{git_root}/**/*_githooks.rb").each do |file|
|
36
|
+
Dir.glob("#{git_root}/githooks/**/*_githooks.rb").each do |file|
|
37
37
|
load file
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
env = Object.new
|
41
41
|
each_hook do |hook|
|
42
|
-
|
43
|
-
hook.call @args
|
42
|
+
env.instance_exec @args, &hook
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
data/lib/githooks/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: -669187955603600665
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
@@ -109,13 +109,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash:
|
112
|
+
hash: -669187955603600665
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 1.8.24
|
116
116
|
signing_key:
|
117
117
|
specification_version: 3
|
118
|
-
summary: A framework to manage git hooks with your
|
118
|
+
summary: A framework to manage git hooks with your repository
|
119
119
|
test_files:
|
120
120
|
- spec/lib/githooks/base_spec.rb
|
121
121
|
- spec/lib/githooks/helper_spec.rb
|