githooks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/githooks +44 -0
- data/githooks.gemspec +19 -0
- data/lib/githooks/base.rb +54 -0
- data/lib/githooks/version.rb +3 -0
- data/lib/githooks.rb +6 -0
- data/lib/hooks/applypatch-msg +8 -0
- data/lib/hooks/commit-msg +8 -0
- data/lib/hooks/post-applypatch +8 -0
- data/lib/hooks/post-checkout +8 -0
- data/lib/hooks/post-commit +8 -0
- data/lib/hooks/post-merge +8 -0
- data/lib/hooks/post-receive +8 -0
- data/lib/hooks/post-rewrite +8 -0
- data/lib/hooks/post-update +8 -0
- data/lib/hooks/pre-applypatch +8 -0
- data/lib/hooks/pre-auto-gc +8 -0
- data/lib/hooks/pre-commit +8 -0
- data/lib/hooks/pre-rebase +8 -0
- data/lib/hooks/pre-receive +8 -0
- data/lib/hooks/prepare-commit-msg +8 -0
- data/lib/hooks/update +8 -0
- metadata +73 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.3-p194@githooks
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Yu Zhang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Githooks
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'githooks'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install githooks
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/githooks
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.dirname($0)
|
3
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'githooks'
|
8
|
+
|
9
|
+
banner = <<-BANNER
|
10
|
+
Usage: githooks [options]
|
11
|
+
|
12
|
+
Description:
|
13
|
+
|
14
|
+
Initializtion and helper script for githooks
|
15
|
+
|
16
|
+
BANNER
|
17
|
+
|
18
|
+
options = OptionParser.new do |opts|
|
19
|
+
opts.banner = banner.gsub(/^ {6}/, '')
|
20
|
+
|
21
|
+
opts.separator ''
|
22
|
+
opts.separator 'Options:'
|
23
|
+
|
24
|
+
opts.on('-i', '--install', 'Install githooks for the current project') do
|
25
|
+
exit unless system("git rev-parse")
|
26
|
+
git_root = `git rev-parse --show-toplevel`.chop
|
27
|
+
gem_root = File.expand_path "..", File.dirname($0)
|
28
|
+
FileUtils.cp_r(Dir["#{gem_root}/gems/githooks-#{Githooks::VERSION}/lib/hooks/*"], "#{git_root}/.git/hooks")
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on( '-l', '--list', 'List supported git hooks') do
|
32
|
+
puts Githooks::HookNames
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on( '-h', '--help', 'Display this help.' ) do
|
37
|
+
puts opts
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
options.parse!
|
43
|
+
|
44
|
+
puts options and exit if ARGV[0].nil?
|
data/githooks.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'githooks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "githooks"
|
8
|
+
gem.version = Githooks::VERSION
|
9
|
+
gem.authors = ["Yu Zhang"]
|
10
|
+
gem.email = ["ian7zy@gmail.com"]
|
11
|
+
gem.description = %q{git hooks framework in Ruby}
|
12
|
+
gem.summary = %q{A framework to manage git hooks with your source code}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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
|
+
module Githooks
|
14
|
+
HookNames = %w[applypatch_msg pre_applypatch post_applypatch
|
15
|
+
pre_commit prepare_commit_msg commit_msg post_commit
|
16
|
+
pre_rebase
|
17
|
+
post_checkout
|
18
|
+
post_merge
|
19
|
+
pre_receive post_receive update post_update
|
20
|
+
pre_auto_gc
|
21
|
+
post_rewrite]
|
22
|
+
class Base
|
23
|
+
def execute
|
24
|
+
lambda {
|
25
|
+
hooks = []
|
26
|
+
Kernel.send :define_method, self.class.name.underscore do |&block|
|
27
|
+
hooks << block
|
28
|
+
end
|
29
|
+
|
30
|
+
Kernel.send :define_method, :each_hook do |&block|
|
31
|
+
hooks.each do |hook|
|
32
|
+
block.call hook
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Kernel.send :define_method, :method_missing do |method, *args|
|
37
|
+
super(method, args) unless Githooks::HookNames.include? method.to_s
|
38
|
+
end
|
39
|
+
}.call
|
40
|
+
|
41
|
+
git_root = `git rev-parse --show-toplevel`.chop
|
42
|
+
|
43
|
+
Dir.glob("#{git_root}/**/*_githooks.rb").each do |file|
|
44
|
+
load file
|
45
|
+
end
|
46
|
+
|
47
|
+
env = Object.new
|
48
|
+
each_hook do |hook|
|
49
|
+
env.instance_eval &hook
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/githooks.rb
ADDED
data/lib/hooks/update
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: githooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yu Zhang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: git hooks framework in Ruby
|
15
|
+
email:
|
16
|
+
- ian7zy@gmail.com
|
17
|
+
executables:
|
18
|
+
- githooks
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .rvmrc
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/githooks
|
29
|
+
- githooks.gemspec
|
30
|
+
- lib/githooks.rb
|
31
|
+
- lib/githooks/base.rb
|
32
|
+
- lib/githooks/version.rb
|
33
|
+
- lib/hooks/applypatch-msg
|
34
|
+
- lib/hooks/commit-msg
|
35
|
+
- lib/hooks/post-applypatch
|
36
|
+
- lib/hooks/post-checkout
|
37
|
+
- lib/hooks/post-commit
|
38
|
+
- lib/hooks/post-merge
|
39
|
+
- lib/hooks/post-receive
|
40
|
+
- lib/hooks/post-rewrite
|
41
|
+
- lib/hooks/post-update
|
42
|
+
- lib/hooks/pre-applypatch
|
43
|
+
- lib/hooks/pre-auto-gc
|
44
|
+
- lib/hooks/pre-commit
|
45
|
+
- lib/hooks/pre-rebase
|
46
|
+
- lib/hooks/pre-receive
|
47
|
+
- lib/hooks/prepare-commit-msg
|
48
|
+
- lib/hooks/update
|
49
|
+
homepage: ''
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.24
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: A framework to manage git hooks with your source code
|
73
|
+
test_files: []
|