Skip to content

Commit baec057

Browse files
committed
Merge branch 'master' into features/csslint
Conflicts: test/unit/pre-commit/cli_test.rb
2 parents f3b5576 + a9872e3 commit baec057

File tree

5 files changed

+68
-13
lines changed

5 files changed

+68
-13
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ rvm:
1010
- 1.9.3
1111
- 2.0.0
1212
- jruby-19mode
13-
- rbx
1413
matrix:
15-
allow_failures:
16-
- rvm: rbx
1714
fast_finish: true

Gemfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,4 @@ group :development do
1111
gem "redcarpet", :platforms => [:mri_20]
1212
gem "simplecov", :platforms => [:mri_20]
1313
gem "coveralls", :platforms => [:mri_20]
14-
15-
# rubinius support
16-
gem "rubysl-json", :platforms => [:rbx]
17-
gem "rubysl-mutex_m", :platforms => [:rbx]
18-
gem "rubysl-open3", :platforms => [:rbx]
19-
gem "rubysl-singleton", :platforms => [:rbx]
20-
gem "rubysl-stringio", :platforms => [:rbx]
2114
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'plugins/pre_commit/configuration/providers/git'
2+
3+
module PreCommit
4+
class Configuration
5+
class Providers
6+
7+
class GitOld < Git
8+
9+
def self.priority
10+
11
11+
end
12+
13+
def [](name)
14+
value = super(name)
15+
if
16+
name == :checks && value && ! value.kind_of?(Array)
17+
then
18+
value = value.chomp.split(/,\s*/).map(&:to_sym) || []
19+
update(name, value) unless value.empty?
20+
end
21+
value
22+
end
23+
24+
end
25+
26+
end
27+
end
28+
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'minitest_helper'
2+
require 'plugins/pre_commit/configuration/providers/git_old'
3+
4+
describe PreCommit::Configuration::Providers::GitOld do
5+
subject do
6+
PreCommit::Configuration::Providers::GitOld
7+
end
8+
9+
it "has priority" do
10+
subject.priority.must_equal(11)
11+
end
12+
13+
describe :filesystem do
14+
before do
15+
create_temp_dir
16+
start_git
17+
sh "git config pre-commit.checks jshint,local"
18+
sh "git config pre-commit.other jshint,local"
19+
end
20+
after(&:destroy_temp_dir)
21+
22+
it "reads values" do
23+
example = subject.new
24+
example[:test1].must_equal(nil)
25+
example[:checks].must_equal([:jshint, :local])
26+
example[:other].must_equal("jshint,local")
27+
end
28+
29+
it "saves values" do
30+
example = subject.new
31+
example[:checks]
32+
example[:other]
33+
sh("git config pre-commit.checks").strip.must_equal("[:jshint, :local]")
34+
sh("git config pre-commit.other").strip.must_equal("jshint,local")
35+
end
36+
end
37+
end

test/unit/pre-commit/cli_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
cli.execute.must_equal(true)
4646
$stderr.string.must_equal('')
4747
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
48-
Available providers: default(0) git(10) yaml(20)
48+
Available providers: default(0) git(10) git_old(11) yaml(20)
4949
Available checks : before_all ci closure coffeelint console_log csslint debugger gemfile_path jshint jslint local merge_conflict migration nb_space php pry rspec_focus rubocop ruby_symbol_hashrockets tabs whitespace
5050
Default checks : white_space console_log debugger pry tabs jshint migrations merge_conflict local nb_space
5151
Enabled checks : white_space console_log debugger pry tabs jshint migrations merge_conflict local nb_space
@@ -74,7 +74,7 @@
7474
cli.execute.must_equal(true)
7575
$stderr.string.must_equal('')
7676
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
77-
Available providers: default(0) git(10) yaml(20)
77+
Available providers: default(0) git(10) git_old(11) yaml(20)
7878
Available checks : before_all ci closure coffeelint console_log csslint debugger gemfile_path jshint jslint local merge_conflict migration nb_space php pry rspec_focus rubocop ruby_symbol_hashrockets tabs whitespace
7979
Default checks : white_space console_log debugger pry tabs jshint migrations merge_conflict local nb_space
8080
Enabled checks : console_log debugger pry tabs jshint migrations merge_conflict local nb_space
@@ -94,7 +94,7 @@
9494
cli.execute.must_equal(true)
9595
$stderr.string.must_equal('')
9696
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
97-
Available providers: default(0) git(10) yaml(20)
97+
Available providers: default(0) git(10) git_old(11) yaml(20)
9898
Available checks : before_all ci closure coffeelint console_log csslint debugger gemfile_path jshint jslint local merge_conflict migration nb_space php pry rspec_focus rubocop ruby_symbol_hashrockets tabs whitespace
9999
Default checks : white_space console_log debugger pry tabs jshint migrations merge_conflict local nb_space
100100
Enabled checks : white_space console_log debugger pry tabs jshint migrations merge_conflict local nb_space

0 commit comments

Comments
 (0)