githooks 0.0.4 → 0.0.5
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/.rspec +2 -0
- data/.travis.yml +10 -0
- data/README.md +7 -1
- data/Rakefile +13 -0
- data/githooks.gemspec +5 -1
- data/lib/githooks/base.rb +4 -16
- data/lib/githooks/string.rb +11 -0
- data/lib/githooks/version.rb +1 -1
- data/lib/githooks.rb +1 -0
- data/spec/lib/githooks/base_spec.rb +15 -0
- data/spec/lib/githooks/helper_spec.rb +20 -0
- data/spec/lib/githooks/string_spec.rb +15 -0
- data/spec/spec_helper.rb +13 -0
- metadata +54 -5
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Githooks
|
1
|
+
# Githooks [](http://travis-ci.org/ianzy/githooks)
|
2
2
|
|
3
3
|
A framework to manage git hooks with your repository. Codes in *_githooks.rb will be executed by the framework.
|
4
4
|
|
@@ -84,3 +84,9 @@ The example hook checks whether the commit message follows the provided pattern.
|
|
84
84
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
85
|
4. Push to the branch (`git push origin my-new-feature`)
|
86
86
|
5. Create new Pull Request
|
87
|
+
|
88
|
+
## TODO
|
89
|
+
|
90
|
+
1. Testing / CI
|
91
|
+
2. Provide git related information in the environment
|
92
|
+
3. Share context across hooks
|
data/Rakefile
CHANGED
@@ -1 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new("spec") do |spec|
|
6
|
+
spec.pattern = "spec/**/*_spec.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new('spec:progress') do |spec|
|
10
|
+
spec.rspec_opts = %w(--format progress)
|
11
|
+
spec.pattern = "spec/**/*_spec.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :spec
|
data/githooks.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Githooks::VERSION
|
9
9
|
gem.authors = ["Yu Zhang"]
|
10
10
|
gem.email = ["ian7zy@gmail.com"]
|
11
|
-
gem.description = %q{git hooks framework in Ruby}
|
11
|
+
gem.description = %q{A git hooks framework in Ruby}
|
12
12
|
gem.summary = %q{A framework to manage git hooks with your source code}
|
13
13
|
gem.homepage = "https://github.com/ianzy/githooks"
|
14
14
|
|
@@ -16,4 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# Development Dependencies
|
21
|
+
gem.add_development_dependency "rake"
|
22
|
+
gem.add_development_dependency "rspec"
|
19
23
|
end
|
data/lib/githooks/base.rb
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
class String
|
2
|
-
def underscore
|
3
|
-
word = self.dup
|
4
|
-
word.gsub!(/::/, '/')
|
5
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
6
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
7
|
-
word.tr!("-", "_")
|
8
|
-
word.downcase!
|
9
|
-
word
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
1
|
module Githooks
|
14
2
|
HookNames = %w[applypatch_msg pre_applypatch post_applypatch
|
15
3
|
pre_commit prepare_commit_msg commit_msg post_commit
|
@@ -23,9 +11,7 @@ module Githooks
|
|
23
11
|
|
24
12
|
def initialize(args = nil)
|
25
13
|
@args = args
|
26
|
-
|
27
|
-
|
28
|
-
def execute
|
14
|
+
|
29
15
|
lambda {
|
30
16
|
hooks = []
|
31
17
|
Kernel.send :define_method, self.class.name.underscore do |&block|
|
@@ -42,7 +28,9 @@ module Githooks
|
|
42
28
|
super(method, args) unless Githooks::HookNames.include? method.to_s
|
43
29
|
end
|
44
30
|
}.call
|
45
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute
|
46
34
|
git_root = `git rev-parse --show-toplevel`.chop
|
47
35
|
|
48
36
|
Dir.glob("#{git_root}/**/*_githooks.rb").each do |file|
|
data/lib/githooks/version.rb
CHANGED
data/lib/githooks.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require (File.expand_path('../../../spec_helper', __FILE__))
|
2
|
+
|
3
|
+
describe Githooks::Base do
|
4
|
+
before(:all) do
|
5
|
+
class TestHook < Githooks::Base
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should created methods for Kernel" do
|
10
|
+
t = TestHook.new
|
11
|
+
respond_to?(:test_hook).should be_true
|
12
|
+
respond_to?(:each_hook).should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require (File.expand_path('../../../spec_helper', __FILE__))
|
2
|
+
|
3
|
+
describe Githooks::Helper do
|
4
|
+
before(:all) do
|
5
|
+
class Subject
|
6
|
+
include Githooks::Helper
|
7
|
+
end
|
8
|
+
@subject = Subject.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".ask" do
|
12
|
+
it "should print question" do
|
13
|
+
@subject.stub!(:gets) {"\n"}
|
14
|
+
@subject.stub!(:print) {""}
|
15
|
+
question = "what's new?"
|
16
|
+
answer = @subject.ask question
|
17
|
+
answer.should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require (File.expand_path('../../../spec_helper', __FILE__))
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
describe ".underscore" do
|
5
|
+
it "should duplicate the string" do
|
6
|
+
str1 = "test"
|
7
|
+
str2 = str1.underscore
|
8
|
+
str1.equal?(str2).should be_false
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should change camel case to underscore" do
|
12
|
+
"ThisIsATest".underscore.should eq "this_is_a_test"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../../lib/githooks', __FILE__)
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
|
8
|
+
# Run specs in random order to surface order dependencies. If you find an
|
9
|
+
# order dependency and want to debug it, you can fix the order by providing
|
10
|
+
# the seed, which is printed after each run.
|
11
|
+
# --seed 1234
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,41 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2012-10-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A git hooks framework in Ruby
|
15
47
|
email:
|
16
48
|
- ian7zy@gmail.com
|
17
49
|
executables:
|
@@ -20,7 +52,9 @@ extensions: []
|
|
20
52
|
extra_rdoc_files: []
|
21
53
|
files:
|
22
54
|
- .gitignore
|
55
|
+
- .rspec
|
23
56
|
- .rvmrc
|
57
|
+
- .travis.yml
|
24
58
|
- Gemfile
|
25
59
|
- LICENSE.txt
|
26
60
|
- README.md
|
@@ -30,6 +64,7 @@ files:
|
|
30
64
|
- lib/githooks.rb
|
31
65
|
- lib/githooks/base.rb
|
32
66
|
- lib/githooks/helper.rb
|
67
|
+
- lib/githooks/string.rb
|
33
68
|
- lib/githooks/version.rb
|
34
69
|
- lib/hooks/applypatch-msg
|
35
70
|
- lib/hooks/commit-msg
|
@@ -47,6 +82,10 @@ files:
|
|
47
82
|
- lib/hooks/pre-receive
|
48
83
|
- lib/hooks/prepare-commit-msg
|
49
84
|
- lib/hooks/update
|
85
|
+
- spec/lib/githooks/base_spec.rb
|
86
|
+
- spec/lib/githooks/helper_spec.rb
|
87
|
+
- spec/lib/githooks/string_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
50
89
|
homepage: https://github.com/ianzy/githooks
|
51
90
|
licenses: []
|
52
91
|
post_install_message:
|
@@ -59,16 +98,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
98
|
- - ! '>='
|
60
99
|
- !ruby/object:Gem::Version
|
61
100
|
version: '0'
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
hash: 3571687485541321288
|
62
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
105
|
none: false
|
64
106
|
requirements:
|
65
107
|
- - ! '>='
|
66
108
|
- !ruby/object:Gem::Version
|
67
109
|
version: '0'
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: 3571687485541321288
|
68
113
|
requirements: []
|
69
114
|
rubyforge_project:
|
70
115
|
rubygems_version: 1.8.24
|
71
116
|
signing_key:
|
72
117
|
specification_version: 3
|
73
118
|
summary: A framework to manage git hooks with your source code
|
74
|
-
test_files:
|
119
|
+
test_files:
|
120
|
+
- spec/lib/githooks/base_spec.rb
|
121
|
+
- spec/lib/githooks/helper_spec.rb
|
122
|
+
- spec/lib/githooks/string_spec.rb
|
123
|
+
- spec/spec_helper.rb
|