able_git_hooks 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 446a17cb50cba29303318ffb537d553528660790c7d4c00c008905265e772002
4
+ data.tar.gz: 1518286407472e48ae91e3b3acab6bbcfef9a3cbff8b1e33a7fba7d961e10557
5
+ SHA512:
6
+ metadata.gz: ba003fafa63f6b1b564b853c18d8557aee7d48619029a47ffd430fc40c65acd77f9fb3f027082bbe19695cfe2e61fc96320095a4a977dd7689d9f57d93f45ffb
7
+ data.tar.gz: 29c3ad73e6baa33e708b8d59dce73328b753d713aab21a724099f991f3308dbc53c73a3a7f163ae3a5cd9b615ec7c5d791e6b79f8d69bfb8a2de8b76dfa8a48c
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ able_git_hooks (0.9.0)
5
+ railties (~> 5.2, >= 5.2.0)
6
+ rubocop (~> 0.57.2, >= 0.57.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (5.2.0)
12
+ actionview (= 5.2.0)
13
+ activesupport (= 5.2.0)
14
+ rack (~> 2.0)
15
+ rack-test (>= 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
+ actionview (5.2.0)
19
+ activesupport (= 5.2.0)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
+ activesupport (5.2.0)
25
+ concurrent-ruby (~> 1.0, >= 1.0.2)
26
+ i18n (>= 0.7, < 2)
27
+ minitest (~> 5.1)
28
+ tzinfo (~> 1.1)
29
+ ast (2.4.0)
30
+ builder (3.2.3)
31
+ concurrent-ruby (1.0.5)
32
+ crass (1.0.4)
33
+ erubi (1.7.1)
34
+ i18n (1.0.1)
35
+ concurrent-ruby (~> 1.0)
36
+ jaro_winkler (1.5.1)
37
+ loofah (2.2.2)
38
+ crass (~> 1.0.2)
39
+ nokogiri (>= 1.5.9)
40
+ method_source (0.9.0)
41
+ mini_portile2 (2.3.0)
42
+ minitest (5.11.3)
43
+ nokogiri (1.8.3)
44
+ mini_portile2 (~> 2.3.0)
45
+ parallel (1.12.1)
46
+ parser (2.5.1.0)
47
+ ast (~> 2.4.0)
48
+ powerpack (0.1.2)
49
+ rack (2.0.5)
50
+ rack-test (1.0.0)
51
+ rack (>= 1.0, < 3)
52
+ rails-dom-testing (2.0.3)
53
+ activesupport (>= 4.2.0)
54
+ nokogiri (>= 1.6)
55
+ rails-html-sanitizer (1.0.4)
56
+ loofah (~> 2.2, >= 2.2.2)
57
+ railties (5.2.0)
58
+ actionpack (= 5.2.0)
59
+ activesupport (= 5.2.0)
60
+ method_source
61
+ rake (>= 0.8.7)
62
+ thor (>= 0.18.1, < 2.0)
63
+ rainbow (3.0.0)
64
+ rake (10.5.0)
65
+ rubocop (0.57.2)
66
+ jaro_winkler (~> 1.5.1)
67
+ parallel (~> 1.10)
68
+ parser (>= 2.5)
69
+ powerpack (~> 0.1)
70
+ rainbow (>= 2.2.2, < 4.0)
71
+ ruby-progressbar (~> 1.7)
72
+ unicode-display_width (~> 1.0, >= 1.0.1)
73
+ ruby-progressbar (1.9.0)
74
+ thor (0.20.0)
75
+ thread_safe (0.3.6)
76
+ tzinfo (1.2.5)
77
+ thread_safe (~> 0.1)
78
+ unicode-display_width (1.4.0)
79
+
80
+ PLATFORMS
81
+ ruby
82
+
83
+ DEPENDENCIES
84
+ able_git_hooks!
85
+ bundler (~> 1.16)
86
+ minitest (~> 5.0)
87
+ rake (~> 10.0)
88
+
89
+ BUNDLED WITH
90
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Able Co
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Able Git Hooks
2
+
3
+ AbleGitHooks installs git hooks so that the scripts can be managed outside of the `.git/hooks` folder.
4
+
5
+ All scripts in the `hooks/<hook_name>` folders will be run and expected to return 0.
6
+
7
+ For example this gem installs a rubocop hook in `hooks/pre-commit/rubocop` that prevents commits
8
+ that do not pass rubocop check.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'able_git_hooks'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ ## Usage
23
+
24
+ Execute the generator command to copy the files:
25
+
26
+ $ bundle exec rails generate able_git_hooks:install
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,32 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require "able_git_hooks/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "able_git_hooks"
8
+ spec.version = AbleGitHooks::VERSION
9
+ spec.authors = ["Mario Rodas", "Gustavo Beathyate"]
10
+ spec.email = ["mario@able.co", "gustavo.bt@able.co"]
11
+
12
+ spec.summary = "Creates an extensible git hooks system on rails projects"
13
+ spec.description = "Adds scripts in .git/hooks to call scripts in the root hooks directory"
14
+ spec.homepage = "http://able.co"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "railties", "~> 5.2", ">= 5.2.0"
27
+ spec.add_dependency "rubocop", "~> 0.57.2", ">= 0.57.2"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "minitest", "~> 5.0"
32
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "able_git_hooks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ require "able_git_hooks/version"
2
+ require "able_git_hooks/railtie"
3
+
4
+ module AbleGitHooks
5
+ SCRIPTS = %w(
6
+ applypatch-msg
7
+ pre-applypatch
8
+ post-applypatch
9
+ pre-commit
10
+ prepare-commit-msg
11
+ commit-msg
12
+ post-commit
13
+ pre-rebase
14
+ post-checkout
15
+ post-merge
16
+ pre-push
17
+ pre-receive
18
+ update
19
+ post-receive
20
+ post-update
21
+ push-to-checkout
22
+ pre-auto-gc
23
+ post-rewrite
24
+ rebase
25
+ sendemail-validate
26
+ )
27
+ end
@@ -0,0 +1,27 @@
1
+ module AbleGitHooks
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Install git hook files"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def install_git_hooks
8
+ copy_file "_do_hook", ".git/hooks/_do_hook"
9
+ chmod ".git/hooks/_do_hook", 0755
10
+
11
+ AbleGitHooks::SCRIPTS.each do |hook|
12
+ create_link ".git/hooks/#{hook}", "_do_hook"
13
+ chmod ".git/hooks/#{hook}", 0755
14
+ end
15
+ end
16
+
17
+ def install_rubocop_hooks
18
+ copy_file "rubocop_hook", "hooks/pre-commit/rubocop"
19
+ chmod "hooks/pre-commit/rubocop", 0755
20
+ end
21
+
22
+ def copy_rubocop_defaults
23
+ template "rubocop.yml", "config/rubocop.yml"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+ set -Eeuo pipefail
3
+
4
+ ARG0=$(basename "${0}")
5
+
6
+ if [ "${ARG0}" = "_do_hook" ]; then
7
+ echo "Do not call this script directly."
8
+ exit 1
9
+ fi
10
+
11
+ declare -r hookdir="hooks/$ARG0"
12
+
13
+ [ -d "$hookdir" ] || exit 0
14
+
15
+ for hook in "$hookdir"/*; do
16
+ echo "executing hook: ${hook}"
17
+ exec "${hook}"
18
+ done
@@ -0,0 +1,117 @@
1
+ ---
2
+ AllCops:
3
+ DisabledByDefault: true
4
+ Exclude:
5
+ - bin/**/*
6
+ - node_modules/**/*
7
+ - db/migrate/*
8
+ - db/schema.rb
9
+ TargetRubyVersion: 2.5
10
+ Layout/AccessModifierIndentation:
11
+ EnforcedStyle: indent
12
+ Layout/BlockAlignment:
13
+ EnforcedStyleAlignWith: either
14
+ Layout/DefEndAlignment:
15
+ EnforcedStyleAlignWith: start_of_line
16
+ Layout/DotPosition:
17
+ EnforcedStyle: leading
18
+ Layout/EmptyComment:
19
+ Enabled: true
20
+ Layout/EmptyLineBetweenDefs:
21
+ Enabled: true
22
+ NumberOfEmptyLines: 1
23
+ Layout/EmptyLinesAroundBlockBody:
24
+ EnforcedStyle: no_empty_lines
25
+ Layout/EmptyLinesAroundClassBody:
26
+ EnforcedStyle: no_empty_lines
27
+ Layout/EmptyLinesAroundModuleBody:
28
+ EnforcedStyle: no_empty_lines
29
+ Layout/EndAlignment:
30
+ EnforcedStyleAlignWith: start_of_line
31
+ Layout/ExtraSpacing:
32
+ AllowForAlignment: true
33
+ Layout/IndentArray:
34
+ EnforcedStyle: consistent
35
+ Layout/IndentHash:
36
+ EnforcedStyle: consistent
37
+ Layout/IndentationConsistency:
38
+ EnforcedStyle: normal
39
+ Layout/IndentationWidth:
40
+ Width: 2
41
+ Layout/SpaceAroundBlockParameters:
42
+ EnforcedStyleInsidePipes: no_space
43
+ Layout/SpaceAroundEqualsInParameterDefault:
44
+ EnforcedStyle: space
45
+ Layout/SpaceAroundOperators:
46
+ Enabled: true
47
+ Layout/SpaceBeforeBlockBraces:
48
+ EnforcedStyle: space
49
+ Layout/SpaceInLambdaLiteral:
50
+ EnforcedStyle: require_no_space
51
+ Layout/SpaceInsideBlockBraces:
52
+ EnforcedStyle: space
53
+ EnforcedStyleForEmptyBraces: no_space
54
+ Layout/SpaceInsideHashLiteralBraces:
55
+ EnforcedStyle: space
56
+ EnforcedStyleForEmptyBraces: no_space
57
+ Layout/SpaceInsideReferenceBrackets:
58
+ EnforcedStyle: no_space
59
+ Layout/SpaceInsideStringInterpolation:
60
+ EnforcedStyle: no_space
61
+ Layout/Tab:
62
+ Enabled: true
63
+ Layout/TrailingWhitespace:
64
+ Enabled: true
65
+ Lint/SafeNavigationChain:
66
+ Enabled: true
67
+ Lint/ShadowedArgument:
68
+ Enabled: true
69
+ Lint/UnusedBlockArgument:
70
+ Enabled: true
71
+ Lint/UnusedMethodArgument:
72
+ Enabled: true
73
+ Naming/VariableName:
74
+ EnforcedStyle: snake_case
75
+ Rails/LexicallyScopedActionFilter:
76
+ Include:
77
+ - app/controllers/**/*.rb
78
+ Rails/TimeZone:
79
+ EnforcedStyle: flexible
80
+ Rails/UnknownEnv:
81
+ Environments:
82
+ - development
83
+ - test
84
+ - production
85
+ Style/BlockDelimiters:
86
+ EnforcedStyle: line_count_based
87
+ Style/BracesAroundHashParameters:
88
+ EnforcedStyle: no_braces
89
+ Style/EmptyElse:
90
+ EnforcedStyle: both
91
+ Style/EmptyMethod:
92
+ EnforcedStyle: expanded
93
+ Style/HashSyntax:
94
+ EnforcedStyle: ruby19_no_mixed_keys
95
+ Style/MethodDefParentheses:
96
+ EnforcedStyle: require_parentheses
97
+ Style/NumericLiterals:
98
+ MinDigits: 5
99
+ Strict: false
100
+ Style/RedundantReturn:
101
+ Enabled: true
102
+ Style/Semicolon:
103
+ Enabled: true
104
+ Style/SingleLineMethods:
105
+ Enabled: true
106
+ Style/StabbyLambdaParentheses:
107
+ EnforcedStyle: require_parentheses
108
+ Style/StringLiterals:
109
+ EnforcedStyle: double_quotes
110
+ Style/StringLiteralsInInterpolation:
111
+ EnforcedStyle: single_quotes
112
+ Style/TrailingCommaInArguments:
113
+ EnforcedStyleForMultiline: no_comma
114
+ Style/TrailingCommaInArrayLiteral:
115
+ EnforcedStyleForMultiline: no_comma
116
+ Style/TrailingCommaInHashLiteral:
117
+ EnforcedStyleForMultiline: no_comma
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -Eeuo pipefail
4
+
5
+ git diff --cached --name-only --diff-filter=ACM | while read -r file; do
6
+ bundle exec rubocop -RP -c config/rubocop.yml --stdin "$file" < <(git show :"$file")
7
+ done
@@ -0,0 +1,9 @@
1
+ require "rails"
2
+
3
+ module AbleGitHooks
4
+ class Railtie < ::Rails::Railtie
5
+ generators do
6
+ require "able_git_hooks/generators/install_generator"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module AbleGitHooks
2
+ VERSION = "0.9.0"
3
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: able_git_hooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Mario Rodas
8
+ - Gustavo Beathyate
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2018-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '5.2'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 5.2.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '5.2'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.2.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: rubocop
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.57.2
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.57.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.57.2
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.57.2
54
+ - !ruby/object:Gem::Dependency
55
+ name: bundler
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.16'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.16'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rake
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '10.0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: minitest
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5.0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.0'
96
+ description: Adds scripts in .git/hooks to call scripts in the root hooks directory
97
+ email:
98
+ - mario@able.co
99
+ - gustavo.bt@able.co
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - able_git_hooks.gemspec
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/able_git_hooks.rb
114
+ - lib/able_git_hooks/generators/install_generator.rb
115
+ - lib/able_git_hooks/generators/templates/_do_hook
116
+ - lib/able_git_hooks/generators/templates/rubocop.yml
117
+ - lib/able_git_hooks/generators/templates/rubocop_hook
118
+ - lib/able_git_hooks/railtie.rb
119
+ - lib/able_git_hooks/version.rb
120
+ homepage: http://able.co
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.7.6
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Creates an extensible git hooks system on rails projects
144
+ test_files: []