git-hooks 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +11 -0
- data/Gemfile +4 -0
- data/README.md +63 -0
- data/git-hooks.gemspec +24 -0
- data/lib/git-hooks.rb +1 -0
- data/lib/git_hooks/pre_commit.rb +13 -0
- data/lib/git_hooks/pre_commit/prevent_master.rb +11 -0
- data/lib/git_hooks/pre_commit/rspec.rb +11 -0
- data/lib/git_hooks/pre_commit/rubocop.rb +25 -0
- data/lib/git_hooks/version.rb +3 -0
- data/lib/ruby-git-hooks.rb +1 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7490ad1bca5dd84e68d6df16993fe86d81b279f0
|
4
|
+
data.tar.gz: 2e79d0d2fffd110bc5d7b52f981d87963b82c85b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ff9584478dba6cf67bc48a8122134b6beac4ffce421a64e26045d3be9d64c17625b2a01ff471c352f1612f6f9de428fafe2208ef35bf6e47cdbd63edbfad1a4
|
7
|
+
data.tar.gz: a41b19354d8965c485dc666d7947622e7ad771a0bb91c9a0db8bc13663ad3593a9f9d0c1cdaac9e584a21d7f41d794804697effe7e350656d3228a710e5208f8
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Documentation:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
# Include gemspec and Rakefile
|
6
|
+
Include:
|
7
|
+
- '**/*.gemspec'
|
8
|
+
- '**/Rakefile'
|
9
|
+
Exclude:
|
10
|
+
- 'vendor/**/*'
|
11
|
+
- 'db/**/*'
|
12
|
+
- 'bin/rails'
|
13
|
+
- 'bin/spring'
|
14
|
+
- 'bin/rake'
|
15
|
+
- 'config/unicorn.rb'
|
16
|
+
|
17
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-06-24 09:50:26 -0300 using RuboCop version 0.23.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 1
|
9
|
+
# Configuration parameters: Exclude.
|
10
|
+
Style/FileName:
|
11
|
+
Enabled: false
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# GitHooks
|
2
|
+
|
3
|
+
Some usefull ruby git hooks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'git-hooks'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install git-hooks
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
By now you will find only some simple hooks to:
|
22
|
+
|
23
|
+
- Prevent commit on master.
|
24
|
+
- Prevent commit with rubocop offences.
|
25
|
+
- prevent commit with broken rspec tests.
|
26
|
+
|
27
|
+
In the future, some validations will be
|
28
|
+
added, such as:
|
29
|
+
|
30
|
+
- ensure hooks exists on ```.git/hooks```
|
31
|
+
|
32
|
+
By now, if you want all this validations, you should include a
|
33
|
+
```.git/hooks/pre-commit``` with:
|
34
|
+
|
35
|
+
```
|
36
|
+
#!/usr/bin/env ruby
|
37
|
+
require 'git-hooks'
|
38
|
+
|
39
|
+
GitHooks::PreCommit.validate
|
40
|
+
```
|
41
|
+
|
42
|
+
If you want specific validation include:
|
43
|
+
```
|
44
|
+
GitHooks::PreCommit::PreventMaster.new.validate
|
45
|
+
```
|
46
|
+
|
47
|
+
```
|
48
|
+
GitHooks::PreCommit::Rspec.new.validate
|
49
|
+
```
|
50
|
+
|
51
|
+
or
|
52
|
+
|
53
|
+
```
|
54
|
+
GitHooks::PreCommit::Rubocop.new.validate
|
55
|
+
```
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it ( https://github.com/stupied4ever/ruby-git-hooks/fork )
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create a new Pull Request
|
data/git-hooks.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'git_hooks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'git-hooks'
|
8
|
+
spec.version = GitHooks::VERSION
|
9
|
+
spec.authors = ['Rafael da Silva Almeida']
|
10
|
+
spec.email = ['eusou@rafaelalmeida.net']
|
11
|
+
spec.summary = %q(Help to keep git hooks organized.)
|
12
|
+
spec.description = %q(It stores git hooks and force git hooks installation.)
|
13
|
+
spec.homepage = 'http://github.com/stupied4ever/ruby-git-hooks'
|
14
|
+
spec.license = 'DWTF'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'rubocop', '~> 0.23'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
|
+
end
|
data/lib/git-hooks.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'git_hooks/pre_commit'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'pre_commit/prevent_master'
|
2
|
+
require_relative 'pre_commit/rspec'
|
3
|
+
require_relative 'pre_commit/rubocop'
|
4
|
+
|
5
|
+
module GitHooks
|
6
|
+
module PreCommit
|
7
|
+
def self.validate
|
8
|
+
PreventMaster.new.validate
|
9
|
+
Rubocop.new.validate
|
10
|
+
Rspec.new.validate
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GitHooks
|
2
|
+
module PreCommit
|
3
|
+
class Rubocop
|
4
|
+
def validate
|
5
|
+
abort 'Check rubocop offences' unless run_rubocop
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
|
11
|
+
|
12
|
+
def changed_ruby_files
|
13
|
+
`git status --porcelain`.split(/\n/)
|
14
|
+
.select { |file| file =~ ADDED_OR_MODIFIED }
|
15
|
+
.map { |file| file.split(' ')[1] }
|
16
|
+
.select { |file| File.extname(file) == '.rb' }
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_rubocop
|
20
|
+
files = changed_ruby_files
|
21
|
+
system("rubocop #{files.join(' ')} --force-exclusion") if files.any?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'git_hooks/pre_commit'
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-hooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rafael da Silva Almeida
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.23'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.23'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
description: It stores git hooks and force git hooks installation.
|
42
|
+
email:
|
43
|
+
- eusou@rafaelalmeida.net
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
50
|
+
- ".rubocop_todo.yml"
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- git-hooks.gemspec
|
54
|
+
- lib/git-hooks.rb
|
55
|
+
- lib/git_hooks/pre_commit.rb
|
56
|
+
- lib/git_hooks/pre_commit/prevent_master.rb
|
57
|
+
- lib/git_hooks/pre_commit/rspec.rb
|
58
|
+
- lib/git_hooks/pre_commit/rubocop.rb
|
59
|
+
- lib/git_hooks/version.rb
|
60
|
+
- lib/ruby-git-hooks.rb
|
61
|
+
homepage: http://github.com/stupied4ever/ruby-git-hooks
|
62
|
+
licenses:
|
63
|
+
- DWTF
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Help to keep git hooks organized.
|
85
|
+
test_files: []
|
86
|
+
has_rdoc:
|