overcommit 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd49b47c55670147b58f3b1f9d24c563af35b589
4
+ data.tar.gz: 986b58c2716ebd051826a84f420e1c568ba98e7e
5
+ SHA512:
6
+ metadata.gz: 555c4a7777514b88d459eff53b03e5be698499273c95d24b0fa39b779f5ab0d2d59334ec497eaca1061852e06ca14b4d69af0fdd8119dbdc40509c069d29a3b5
7
+ data.tar.gz: d4e0f5ce2ca1c0a5af8f430c65e7f485c3936837e09659f460e489d8f11cfcf30731ac4fd331984816ecb501cffeaff0e87624911c8cabb93e16be8d21580f5b
@@ -11,10 +11,9 @@ module Overcommit::GitHook
11
11
  end
12
12
 
13
13
  paths_to_staged_files = Hash[staged.map { |s| [s.path, s] }]
14
- staged_files = paths_to_staged_files.keys
15
14
 
16
- output = `scss-lint #{staged_files.join(' ')} 2>&1`
17
- return :good if $?.success?
15
+ success, output = run_scss_lint
16
+ return :good if success
18
17
 
19
18
  # Keep lines from the output for files that we actually modified
20
19
  error_lines, warning_lines = output.lines.partition do |output_line|
@@ -32,5 +31,36 @@ module Overcommit::GitHook
32
31
  return :warn, "Modified files have lints (on lines you didn't modify)\n" <<
33
32
  warning_lines.join
34
33
  end
34
+
35
+ private
36
+
37
+ def run_scss_lint
38
+ success, output = true, ''
39
+ scss_lint_config_mapping.each do |config, files|
40
+ config = config ? "-c #{config}" : ''
41
+ output += `scss-lint #{config} #{files.join(' ')} 2>&1`
42
+ success = success && $?.success?
43
+ end
44
+ [success, output]
45
+ end
46
+
47
+ def scss_lint_config_mapping
48
+ staged.inject({}) do |mapping, file|
49
+ config = scss_lint_yml_for(file)
50
+ mapping[config] ||= []
51
+ mapping[config] << file.path
52
+ mapping
53
+ end
54
+ end
55
+
56
+ def scss_lint_yml_for(staged_file)
57
+ possible_files(staged_file.original_path).find { |path| path.file? }
58
+ end
59
+
60
+ def possible_files(file_path)
61
+ files = Pathname.new(file_path).enum_for(:ascend).
62
+ map { |path| path + '.scss-lint.yml' }
63
+ files << Pathname.new('.scss-lint.yml')
64
+ end
35
65
  end
36
66
  end
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,64 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
- version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Causes Engineering
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-11-08 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - "="
28
- - !ruby/object:Gem::Version
29
- hash: 59
30
- segments:
31
- - 2
32
- - 13
33
- - 0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
34
19
  version: 2.13.0
35
20
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: image_optim
39
21
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
45
- hash: 57
46
- segments:
47
- - 0
48
- - 9
49
- - 1
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: image_optim
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
50
33
  version: 0.9.1
51
34
  type: :development
52
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.1
53
41
  description: Overcommit is a utility to install and extend Git hooks
54
42
  email: eng@causes.com
55
- executables:
43
+ executables:
56
44
  - overcommit
57
45
  extensions: []
58
-
59
46
  extra_rdoc_files: []
60
-
61
- files:
47
+ files:
62
48
  - lib/overcommit.rb
63
49
  - lib/overcommit/version.rb
64
50
  - lib/overcommit/utils.rb
@@ -110,39 +96,29 @@ files:
110
96
  - bin/hooks/pre-commit
111
97
  - bin/hooks/prepare-commit-msg
112
98
  - config/templates.yml
113
- has_rdoc: true
114
99
  homepage: http://github.com/causes/overcommit
115
- licenses:
100
+ licenses:
116
101
  - MIT
102
+ metadata: {}
117
103
  post_install_message:
118
104
  rdoc_options: []
119
-
120
- require_paths:
105
+ require_paths:
121
106
  - lib
122
- required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
131
- required_rubygems_version: !ruby/object:Gem::Requirement
132
- none: false
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- hash: 3
137
- segments:
138
- - 0
139
- version: "0"
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
140
117
  requirements: []
141
-
142
118
  rubyforge_project:
143
- rubygems_version: 1.3.7
119
+ rubygems_version: 2.0.2
144
120
  signing_key:
145
- specification_version: 3
121
+ specification_version: 4
146
122
  summary: Opinionated Git hook manager
147
123
  test_files: []
148
-
124
+ has_rdoc: