git-precommit 1.2.3 → 1.2.4
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/.gitignore +5 -1
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +49 -0
- data/Rakefile +14 -14
- data/config/cucumber.yml +12 -0
- data/features/draconian.feature +27 -0
- data/features/pre-commit.feature +28 -0
- data/features/support/setup.rb +1 -0
- data/git-precommit.gemspec +27 -40
- data/lib/git-precommit/precommit_tasks.rb +21 -4
- data/lib/git-precommit/tasks.rb +2 -1
- data/lib/git-precommit/version.rb +3 -0
- data/lib/git_precommit.rb +1 -0
- data/tasks/cucumber.rake +53 -0
- metadata +89 -11
- data/VERSION +0 -1
data/.gitignore
CHANGED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create @git-precommit
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
git-precommit (1.2.4)
|
5
|
+
rake
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.2.3)
|
11
|
+
background_process
|
12
|
+
cucumber (~> 0.9.0)
|
13
|
+
background_process (1.2)
|
14
|
+
builder (2.1.2)
|
15
|
+
cucumber (0.9.2)
|
16
|
+
builder (~> 2.1.2)
|
17
|
+
diff-lcs (~> 1.1.2)
|
18
|
+
gherkin (~> 2.2.5)
|
19
|
+
json (~> 1.4.6)
|
20
|
+
term-ansicolor (~> 1.0.5)
|
21
|
+
diff-lcs (1.1.2)
|
22
|
+
gherkin (2.2.9)
|
23
|
+
json (~> 1.4.6)
|
24
|
+
term-ansicolor (~> 1.0.5)
|
25
|
+
json (1.4.6)
|
26
|
+
rake (0.8.7)
|
27
|
+
rspec (2.0.0)
|
28
|
+
rspec-core (= 2.0.0)
|
29
|
+
rspec-expectations (= 2.0.0)
|
30
|
+
rspec-mocks (= 2.0.0)
|
31
|
+
rspec-core (2.0.0)
|
32
|
+
rspec-expectations (2.0.0)
|
33
|
+
diff-lcs (>= 1.1.2)
|
34
|
+
rspec-mocks (2.0.0)
|
35
|
+
rspec-core (= 2.0.0)
|
36
|
+
rspec-expectations (= 2.0.0)
|
37
|
+
syntax (1.0.0)
|
38
|
+
term-ansicolor (1.0.5)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
aruba
|
45
|
+
cucumber (~> 0.9.0)
|
46
|
+
git-precommit!
|
47
|
+
rake
|
48
|
+
rspec (~> 2.0.0)
|
49
|
+
syntax
|
data/Rakefile
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/rdoctask"
|
3
|
+
|
1
4
|
begin
|
2
|
-
require '
|
3
|
-
|
4
|
-
gemspec.name = "git-precommit"
|
5
|
-
gemspec.summary = "Fail commits if the tests fail."
|
6
|
-
gemspec.description = <<-EOS
|
7
|
-
A set of rake tasks that install git pre-commit hooks to call your build.
|
8
|
-
If your build fails, the commit will not proceed.
|
9
|
-
EOS
|
10
|
-
gemspec.email = "toby.tripp+git@gmail.com"
|
11
|
-
gemspec.homepage = "http://github.com/tobytripp/git-pre-commit"
|
12
|
-
gemspec.authors = ["Toby Tripp"]
|
13
|
-
end
|
14
|
-
Jeweler::GemcutterTasks.new
|
5
|
+
require 'bundler/setup'
|
6
|
+
Bundler::GemHelper.install_tasks
|
15
7
|
rescue LoadError
|
16
|
-
puts "
|
8
|
+
puts "Bundler not available. Install it with: gem install bundler"
|
17
9
|
end
|
10
|
+
|
11
|
+
Dir["./tasks/**/*.rake"].each { |task| load task }
|
12
|
+
|
13
|
+
require "git_precommit"
|
14
|
+
GitPrecommit::PrecommitTasks.new
|
15
|
+
|
16
|
+
task :default => ".git/hooks/pre-commit"
|
17
|
+
task :precommit => :default
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ?
|
4
|
+
"--format progress features" :
|
5
|
+
"--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
6
|
+
std_opts =
|
7
|
+
"#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
|
8
|
+
html_opts =
|
9
|
+
"--format html --out log/cucumber.out.html"
|
10
|
+
%>
|
11
|
+
default: <%= std_opts %>
|
12
|
+
wip: --tags @wip:10 --wip features
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env cucumber
|
2
|
+
Feature: Draconian option
|
3
|
+
Background:
|
4
|
+
Given a directory named ".git/hooks"
|
5
|
+
And a file named "Rakefile" with:
|
6
|
+
"""
|
7
|
+
require "../../lib/git_precommit"
|
8
|
+
GitPrecommit::PrecommitTasks.new :draconian => true
|
9
|
+
|
10
|
+
task :default => ".git/hooks/pre-commit"
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: No pre-commit hook is installed
|
14
|
+
When I successfully run "rake"
|
15
|
+
|
16
|
+
Then the following files should exist:
|
17
|
+
| .git/hooks/pre-commit |
|
18
|
+
|
19
|
+
Scenario: The pre-commit hook is modified
|
20
|
+
When I append to ".git/hooks/pre-commit" with:
|
21
|
+
"""
|
22
|
+
echo "My new hook!"
|
23
|
+
"""
|
24
|
+
|
25
|
+
And I successfully run "rake"
|
26
|
+
|
27
|
+
Then the file ".git/hooks/pre-commit" should not contain "echo"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env cucumber
|
2
|
+
Feature: Pre commit hook installation
|
3
|
+
Background:
|
4
|
+
Given a directory named ".git/hooks"
|
5
|
+
And a file named "Rakefile" with:
|
6
|
+
"""
|
7
|
+
require "../../lib/git_precommit"
|
8
|
+
GitPrecommit::PrecommitTasks.new
|
9
|
+
|
10
|
+
task :default => ".git/hooks/pre-commit"
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: No pre-commit hook is installed
|
14
|
+
When I successfully run "rake"
|
15
|
+
|
16
|
+
Then the following files should exist:
|
17
|
+
| .git/hooks/pre-commit |
|
18
|
+
|
19
|
+
Scenario: The pre-commit hook is modified
|
20
|
+
When I append to ".git/hooks/pre-commit" with:
|
21
|
+
"""
|
22
|
+
echo "My new hook!"
|
23
|
+
"""
|
24
|
+
|
25
|
+
And I successfully run "rake --trace"
|
26
|
+
|
27
|
+
Then the file ".git/hooks/pre-commit" should contain "echo"
|
28
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba'
|
data/git-precommit.gemspec
CHANGED
@@ -1,51 +1,38 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "git-precommit/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = %q{git-precommit}
|
8
|
-
s.version =
|
7
|
+
s.version = GitPrecommit::VERSION
|
9
8
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = %q{2010-03-10}
|
13
|
-
s.default_executable = %q{setpairs}
|
14
|
-
s.description = %q{ A set of rake tasks that install git pre-commit hooks to call your build.
|
15
|
-
If your build fails, the commit will not proceed.
|
16
|
-
}
|
17
|
-
s.email = %q{toby.tripp+git@gmail.com}
|
18
|
-
s.executables = ["setpairs"]
|
19
|
-
s.extra_rdoc_files = [
|
20
|
-
"README.rdoc"
|
21
|
-
]
|
22
|
-
s.files = [
|
23
|
-
".gitignore",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"bin/setpairs",
|
28
|
-
"git-hooks/post-commit",
|
29
|
-
"git-hooks/pre-commit",
|
30
|
-
"git-precommit.gemspec",
|
31
|
-
"lib/git-precommit/precommit_tasks.rb",
|
32
|
-
"lib/git-precommit/tasks.rb",
|
33
|
-
"lib/git_precommit.rb"
|
34
|
-
]
|
9
|
+
s.authors = ["Toby Tripp"]
|
10
|
+
s.email = %q{toby.tripp+git@gmail.com}
|
35
11
|
s.homepage = %q{http://github.com/tobytripp/git-pre-commit}
|
36
|
-
|
37
|
-
s.
|
12
|
+
|
13
|
+
s.summary = %q{Abort git commit if the tests fail.}
|
14
|
+
s.description = %q{
|
15
|
+
A set of rake tasks that install git pre-commit hooks to run your tests.
|
16
|
+
If your build fails, the commit will not proceed.
|
17
|
+
|
18
|
+
Git-precommit will call `rake precommit` to run your tests. Be sure to define this task.
|
19
|
+
}
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
|
25
|
+
s.extra_rdoc_files = %w[README.rdoc]
|
26
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
27
|
s.rubygems_version = %q{1.3.6}
|
39
|
-
s.summary = %q{Fail commits if the tests fail.}
|
40
28
|
|
41
|
-
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
-
s.specification_version = 3
|
29
|
+
s.rubyforge_project = "git-precommit"
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
31
|
+
s.add_dependency "rake"
|
32
|
+
|
33
|
+
s.add_development_dependency "rspec", "~> 2.0.0"
|
34
|
+
s.add_development_dependency "cucumber", "~> 0.9.0"
|
35
|
+
s.add_development_dependency "aruba"
|
36
|
+
s.add_development_dependency "syntax"
|
50
37
|
end
|
51
38
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
2
|
require "rake"
|
3
3
|
require "rake/tasklib"
|
4
4
|
|
@@ -8,7 +8,11 @@ module GitPrecommit
|
|
8
8
|
File.expand_path File.join( File.dirname(__FILE__), '..', '..', 'git-hooks' )
|
9
9
|
attr_accessor :template_path
|
10
10
|
|
11
|
-
def initialize()
|
11
|
+
def initialize( options={} )
|
12
|
+
@options = {
|
13
|
+
:draconian => false
|
14
|
+
}.merge options
|
15
|
+
|
12
16
|
yield self if block_given?
|
13
17
|
@template_path ||= TEMPLATE_PATH
|
14
18
|
|
@@ -16,8 +20,21 @@ module GitPrecommit
|
|
16
20
|
end
|
17
21
|
|
18
22
|
def define()
|
23
|
+
pre_commit = ".git/hooks/pre-commit"
|
24
|
+
pre_commit_src = "#{template_path}/pre-commit"
|
25
|
+
|
26
|
+
task :overwrite do |t|
|
27
|
+
if @options[:draconian]
|
28
|
+
copy pre_commit_src, pre_commit
|
29
|
+
chmod 0755, pre_commit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
deps = [pre_commit_src]
|
34
|
+
deps += [:overwrite] if @options[:draconian]
|
35
|
+
|
19
36
|
desc "Install the git pre-commit hook"
|
20
|
-
file
|
37
|
+
file pre_commit => deps do |t|
|
21
38
|
warn "Git pre-commit hook missing, setting up…"
|
22
39
|
copy t.prerequisites.first, t.name
|
23
40
|
chmod 0755, t.name
|
@@ -31,7 +48,7 @@ module GitPrecommit
|
|
31
48
|
|
32
49
|
namespace :git do
|
33
50
|
desc "Install the git pre-commit hook"
|
34
|
-
task :precommit =>
|
51
|
+
task :precommit => pre_commit
|
35
52
|
|
36
53
|
desc "Install the git post-commit hook"
|
37
54
|
task :postcommit => ".git/hooks/post-commit"
|
data/lib/git-precommit/tasks.rb
CHANGED
@@ -2,10 +2,11 @@ if defined? Rails
|
|
2
2
|
ENVIRONMENT = Rails.env
|
3
3
|
else
|
4
4
|
ENVIRONMENT = RAILS_ENV if defined? RAILS_ENV
|
5
|
+
ENVIRONMENT ||= ENV["RACK_ENV"] if ENV["RACK_ENV"]
|
5
6
|
ENVIRONMENT ||= "development"
|
6
7
|
end
|
7
8
|
|
8
|
-
if %w[development test].include? ENVIRONMENT
|
9
|
+
if %w[development cucumber test].include? ENVIRONMENT
|
9
10
|
require "git_precommit"
|
10
11
|
|
11
12
|
GitPrecommit::PrecommitTasks.new
|
data/lib/git_precommit.rb
CHANGED
data/tasks/cucumber.rake
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
task :default => [:cucumber]
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
namespace :cucumber do
|
7
|
+
Cucumber::Rake::Task.new( :ok,
|
8
|
+
'Run features that should pass') do |t|
|
9
|
+
t.fork = true # You may get faster startup if you set this to false
|
10
|
+
t.profile = 'default'
|
11
|
+
end
|
12
|
+
|
13
|
+
Cucumber::Rake::Task.new(:wip,
|
14
|
+
'Run features that are being worked on') do |t|
|
15
|
+
t.fork = true # You may get faster startup if you set this to false
|
16
|
+
t.profile = 'wip'
|
17
|
+
end
|
18
|
+
|
19
|
+
Cucumber::Rake::Task.new( :cruise,
|
20
|
+
"Run features and generate HTML report" ) do |t|
|
21
|
+
t.fork = true
|
22
|
+
t.profile = 'cruise'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Run all features'
|
26
|
+
task :all => [:ok, :wip]
|
27
|
+
|
28
|
+
desc 'list uncommented feature and scenario names'
|
29
|
+
task :list, [:file_pattern] do |t, args|
|
30
|
+
scenario_count = 0
|
31
|
+
Dir["#{RUBY_ROOT}/features/**/#{args.file_pattern || '*'}.feature"].sort.each do |file|
|
32
|
+
puts file
|
33
|
+
File.read(file).split(/\n/).each do |line|
|
34
|
+
puts $1 if line =~ /^\s*(Feature:.+)/
|
35
|
+
printf("\t%3d:%s\n", scenario_count += 1, $1) if line =~ /^\s*Scenario:(.+)/
|
36
|
+
end
|
37
|
+
puts
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Alias for cucumber:ok'
|
43
|
+
task :cucumber => 'cucumber:ok'
|
44
|
+
|
45
|
+
task :features => :cucumber do
|
46
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
47
|
+
end
|
48
|
+
rescue LoadError
|
49
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
50
|
+
task :cucumber do
|
51
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 4
|
9
|
+
version: 1.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Toby Tripp
|
@@ -14,11 +14,79 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
18
|
-
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
|
17
|
+
date: 2010-11-04 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 2.0.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: cucumber
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
- 9
|
59
|
+
- 0
|
60
|
+
version: 0.9.0
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: aruba
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: syntax
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
type: :development
|
88
|
+
version_requirements: *id005
|
89
|
+
description: "\n A set of rake tasks that install git pre-commit hooks to run your tests.\n If your build fails, the commit will not proceed.\n \n Git-precommit will call `rake precommit` to run your tests. Be sure to define this task.\n "
|
22
90
|
email: toby.tripp+git@gmail.com
|
23
91
|
executables:
|
24
92
|
- setpairs
|
@@ -28,16 +96,24 @@ extra_rdoc_files:
|
|
28
96
|
- README.rdoc
|
29
97
|
files:
|
30
98
|
- .gitignore
|
99
|
+
- .rvmrc
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
31
102
|
- README.rdoc
|
32
103
|
- Rakefile
|
33
|
-
- VERSION
|
34
104
|
- bin/setpairs
|
105
|
+
- config/cucumber.yml
|
106
|
+
- features/draconian.feature
|
107
|
+
- features/pre-commit.feature
|
108
|
+
- features/support/setup.rb
|
35
109
|
- git-hooks/post-commit
|
36
110
|
- git-hooks/pre-commit
|
37
111
|
- git-precommit.gemspec
|
38
112
|
- lib/git-precommit/precommit_tasks.rb
|
39
113
|
- lib/git-precommit/tasks.rb
|
114
|
+
- lib/git-precommit/version.rb
|
40
115
|
- lib/git_precommit.rb
|
116
|
+
- tasks/cucumber.rake
|
41
117
|
has_rdoc: true
|
42
118
|
homepage: http://github.com/tobytripp/git-pre-commit
|
43
119
|
licenses: []
|
@@ -48,6 +124,7 @@ rdoc_options:
|
|
48
124
|
require_paths:
|
49
125
|
- lib
|
50
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
51
128
|
requirements:
|
52
129
|
- - ">="
|
53
130
|
- !ruby/object:Gem::Version
|
@@ -55,6 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
132
|
- 0
|
56
133
|
version: "0"
|
57
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
58
136
|
requirements:
|
59
137
|
- - ">="
|
60
138
|
- !ruby/object:Gem::Version
|
@@ -63,10 +141,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
141
|
version: "0"
|
64
142
|
requirements: []
|
65
143
|
|
66
|
-
rubyforge_project:
|
67
|
-
rubygems_version: 1.3.
|
144
|
+
rubyforge_project: git-precommit
|
145
|
+
rubygems_version: 1.3.7
|
68
146
|
signing_key:
|
69
147
|
specification_version: 3
|
70
|
-
summary:
|
148
|
+
summary: Abort git commit if the tests fail.
|
71
149
|
test_files: []
|
72
150
|
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.3
|