commit_checker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +48 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +65 -0
- data/Readme.md +0 -0
- data/commit_checker.gemspec +16 -0
- data/lib/commit_checker/task.rb +11 -0
- data/lib/commit_checker/tasks/hooks.rake +57 -0
- data/lib/commit_checker/tasks/pre-commit.template.rb +26 -0
- data/lib/commit_checker.rb +3 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c65359a42953c26a1cde2971b6d3834a5c860b3e
|
4
|
+
data.tar.gz: 0e0dee639d4e3637afb94f8f0a90ba96611ce7af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 360bac921242878f672eb8c060f7c9cdb78556cf7ff6010527427dc82dcff2f6bceb96d673aa24c2b801127a551b7596cfede5d0f9e4be9c5e57d85e32c375d8
|
7
|
+
data.tar.gz: c213f99f17fe2330249ff0ff5d60d66bd27dc83f71976d724ff554c5a01816aae934aa826b37ee33f0a1adf8276557ea389ec5024dea24b7f7e037aad73412c1
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.bundle/
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# to see potential flags to enable/disable, check out github.com/bbatsov/rubocop/blob/master/config/
|
2
|
+
|
3
|
+
Encoding:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
LineLength:
|
7
|
+
Enabled: true
|
8
|
+
Max: 160
|
9
|
+
|
10
|
+
HashSyntax:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
StringLiterals:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
IfUnlessModifier:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
WhileUntilModifier:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
SpaceInsideHashLiteralBraces:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
MethodLength:
|
26
|
+
Enabled: true
|
27
|
+
Max: 50
|
28
|
+
|
29
|
+
RedundantSelf:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/GuardClause:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Void:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
WordArray:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/BlockComments:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
AssignmentInCondition:
|
48
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
commit_checker
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
commit_checker (0.0.1)
|
5
|
+
highline
|
6
|
+
railties
|
7
|
+
rubocop
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (4.1.4)
|
13
|
+
actionview (= 4.1.4)
|
14
|
+
activesupport (= 4.1.4)
|
15
|
+
rack (~> 1.5.2)
|
16
|
+
rack-test (~> 0.6.2)
|
17
|
+
actionview (4.1.4)
|
18
|
+
activesupport (= 4.1.4)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
activesupport (4.1.4)
|
22
|
+
i18n (~> 0.6, >= 0.6.9)
|
23
|
+
json (~> 1.7, >= 1.7.7)
|
24
|
+
minitest (~> 5.1)
|
25
|
+
thread_safe (~> 0.1)
|
26
|
+
tzinfo (~> 1.1)
|
27
|
+
ast (2.0.0)
|
28
|
+
builder (3.2.2)
|
29
|
+
erubis (2.7.0)
|
30
|
+
highline (1.6.21)
|
31
|
+
i18n (0.6.11)
|
32
|
+
json (1.8.1)
|
33
|
+
minitest (5.4.0)
|
34
|
+
parser (2.2.0.pre.3)
|
35
|
+
ast (>= 1.1, < 3.0)
|
36
|
+
slop (~> 3.4, >= 3.4.5)
|
37
|
+
powerpack (0.0.9)
|
38
|
+
rack (1.5.2)
|
39
|
+
rack-test (0.6.2)
|
40
|
+
rack (>= 1.0)
|
41
|
+
railties (4.1.4)
|
42
|
+
actionpack (= 4.1.4)
|
43
|
+
activesupport (= 4.1.4)
|
44
|
+
rake (>= 0.8.7)
|
45
|
+
thor (>= 0.18.1, < 2.0)
|
46
|
+
rainbow (2.0.0)
|
47
|
+
rake (10.3.2)
|
48
|
+
rubocop (0.24.1)
|
49
|
+
json (>= 1.7.7, < 2)
|
50
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
51
|
+
powerpack (~> 0.0.6)
|
52
|
+
rainbow (>= 1.99.1, < 3.0)
|
53
|
+
ruby-progressbar (~> 1.4)
|
54
|
+
ruby-progressbar (1.5.1)
|
55
|
+
slop (3.5.0)
|
56
|
+
thor (0.19.1)
|
57
|
+
thread_safe (0.3.4)
|
58
|
+
tzinfo (1.2.1)
|
59
|
+
thread_safe (~> 0.1)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
commit_checker!
|
data/Readme.md
ADDED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'commit_checker'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2014-07-14'
|
5
|
+
s.summary = "Commit Checker"
|
6
|
+
s.description = "A simple gem which help setup hook to check commit"
|
7
|
+
s.authors = ["Hieu Nguyen"]
|
8
|
+
s.email = 'hieu.nguyen@eastagile.com'
|
9
|
+
s.files = `git ls-files`.split($/)
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
s.homepage = ''
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.add_dependency 'railties', '4.1.4'
|
14
|
+
s.add_dependency 'rubocop', '0.24.1'
|
15
|
+
s.add_dependency 'highline', '1.6.21'
|
16
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
namespace :hooks do
|
5
|
+
desc 'Install necessary git hooks'
|
6
|
+
task :install do
|
7
|
+
hooks = %w[
|
8
|
+
applypatch-msg
|
9
|
+
pre-applypatch
|
10
|
+
post-applypatch
|
11
|
+
pre-commit
|
12
|
+
prepare-commit-msg
|
13
|
+
commit-msg
|
14
|
+
post-commit
|
15
|
+
pre-rebase
|
16
|
+
post-checkout
|
17
|
+
post-merge
|
18
|
+
pre-receive
|
19
|
+
update
|
20
|
+
post-receive
|
21
|
+
post-update
|
22
|
+
pre-auto-gc
|
23
|
+
]
|
24
|
+
|
25
|
+
hooks.each do |hook|
|
26
|
+
repo_hook_path = "#{File.dirname(__FILE__)}/#{hook}.template.rb"
|
27
|
+
git_hook_path = "#{Rails.root}/.git/hooks/#{hook}"
|
28
|
+
|
29
|
+
if File.exists?(repo_hook_path)
|
30
|
+
|
31
|
+
if File.exists?(git_hook_path) || File.symlink?(git_hook_path)
|
32
|
+
should_continue = ''
|
33
|
+
while %w[y yes no n].exclude?(should_continue.downcase)
|
34
|
+
should_continue = ask("Warning: #{git_hook_path} already exists. Overwrite it? [y/n]: ")
|
35
|
+
Open3.capture3("rm -f #{git_hook_path}")
|
36
|
+
end
|
37
|
+
break if %w[no n].include?(should_continue.downcase)
|
38
|
+
end
|
39
|
+
|
40
|
+
stdout_str, stderr_str, status = Open3.capture3("cp #{repo_hook_path} #{git_hook_path}")
|
41
|
+
|
42
|
+
stdout_str, stderr_str, status = Open3.capture3("chmod 755 #{git_hook_path}")
|
43
|
+
raise "error: #{stderr_str} for #{hook} when setting permissions to 755" unless status.success?
|
44
|
+
|
45
|
+
stdout_str, stderr_str, status = Open3.capture3("chmod +x #{git_hook_path}")
|
46
|
+
raise "error: #{stderr_str} for #{hook} when making executable (chmod +x)" unless status.success?
|
47
|
+
|
48
|
+
if status.success?
|
49
|
+
puts "installed #{hook}: copied #{git_hook_path} -> #{repo_hook_path}"
|
50
|
+
puts "If you have trouble running your git hook, try changing the shebang line (#!) in #{repo_hook_path}"
|
51
|
+
else
|
52
|
+
raise "error: #{stderr_str} for #{hook}" unless status.success?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# run committed files against the ruby style guide.
|
4
|
+
require 'open3'
|
5
|
+
stdout, stderr, status = Open3.capture3("git diff --name-only --cached | grep -E '#{%w[rb rake].map{|ext| '\.' + ext}.join('|')}' ")
|
6
|
+
modified_files = stdout.split(/\n/)
|
7
|
+
if modified_files.count > 0
|
8
|
+
$stdout.puts("Code conventions: running files against rubocop (https://github.com/bbatsov/rubocop/):")
|
9
|
+
$stdout.puts(modified_files.join("\n "))
|
10
|
+
stdout, stderr, status = Open3.capture3("rubocop #{modified_files.join(' ')}")
|
11
|
+
if status.exitstatus != 0
|
12
|
+
$stdout.puts(stdout)
|
13
|
+
$stdout.puts("*******************************************************************************************")
|
14
|
+
$stdout.puts("The files you committed need cleanup! Many of the warnings are probably old and not yours.")
|
15
|
+
$stdout.puts("We need your help with cleaning. If you think some errors should be ignored, edit .rubocop.yml")
|
16
|
+
$stdout.puts("You might also try running 'rubocop $your_file --auto-correct', but review the changes!")
|
17
|
+
$stdout.puts("*******************************************************************************************")
|
18
|
+
exit 1
|
19
|
+
else
|
20
|
+
$stdout.puts("Files passed Rubocop!")
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# if you want to add your own pre-commit logic, consider what would happen if one or many checks worked or failed,
|
26
|
+
# i.e. a sub_routines: [{ name: foo, status: some_value },...]
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: commit_checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hieu Nguyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.24.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.24.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: highline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.21
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.21
|
55
|
+
description: A simple gem which help setup hook to check commit
|
56
|
+
email: hieu.nguyen@eastagile.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- Readme.md
|
68
|
+
- commit_checker.gemspec
|
69
|
+
- lib/commit_checker.rb
|
70
|
+
- lib/commit_checker/task.rb
|
71
|
+
- lib/commit_checker/tasks/hooks.rake
|
72
|
+
- lib/commit_checker/tasks/pre-commit.template.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.0
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Commit Checker
|
97
|
+
test_files: []
|