zapwhite 2.12.0 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 038fda06031093bd065f07b36c8f3061f93d50a2
4
- data.tar.gz: 5c3d7877a7b4f36b7bfb147f0e1592baddd873bb
3
+ metadata.gz: 8435f3678c780c9f8c20c3f01fb6e10593589090
4
+ data.tar.gz: 51ec2d14cba5a0d3b52e41a7c2115cd68ddfdef8
5
5
  SHA512:
6
- metadata.gz: 971949b8bb3b86b2679a233701f3f6dbf285457b3bbc8575b21551231511ffd65abcb6e48eee37d36f6cc759a33cebd7af69f5285f1ce25b92fa5c4edf4b1833
7
- data.tar.gz: cc09800fc1a734a2d85175960eb3ac8c798746ef7a35d0a79da793ed08e17289b9f3ea603d8b02a02cadca7532ade00726cd82be7f1d00bf1b3489ff601818cb
6
+ metadata.gz: a250a0c649f15cac854399eb8ee4a53a8a750065d2f2bbe79a2ad99d285d3e21ecbe66a1d3a350255f99aca653d2675db3d454e070652118381624827a117a2e
7
+ data.tar.gz: 63566b1ce95451e78a39cbcb1ba33f550dc231f22c12802e6d817d456ffc1c5ec00d8f51f9577d5312a05c2c34226460d2da026aa7dcae6f4c01bdfe9b6db1d2
@@ -80,8 +80,8 @@ module Reality
80
80
 
81
81
  content =
82
82
  config[:dos] ?
83
- clean_dos_whitespace(filename, content, config[:eofnl]) :
84
- clean_whitespace(filename, content, config[:eofnl])
83
+ clean_dos_whitespace(filename, content, config[:eofnl], config[:allow_empty]) :
84
+ clean_whitespace(filename, content, config[:eofnl], config[:allow_empty])
85
85
  if config[:nodupnl]
86
86
  while content.gsub!(/\n\n\n/, "\n\n")
87
87
  # Keep removing duplicate new lines till they have gone
@@ -136,6 +136,7 @@ module Reality
136
136
  files[f] = {
137
137
  :dos => (attr['eol'] == 'crlf'),
138
138
  :encoding => attr['encoding'],
139
+ :allow_empty => attr['allow_empty'].nil? ? false : !!attr['allow_empty'],
139
140
  :nodupnl => attr['dupnl'].nil? ? false : !attr['dupnl'],
140
141
  :eofnl => attr['eofnl'].nil? ? true : !!attr['eofnl']
141
142
  }
@@ -154,7 +155,7 @@ module Reality
154
155
  end
155
156
  end
156
157
 
157
- def clean_whitespace(filename, content, eofnl)
158
+ def clean_whitespace(filename, content, eofnl, allow_empty)
158
159
  begin
159
160
  content.gsub!(/\r\n/, "\n")
160
161
  content.gsub!(/[ \t]+\n/, "\n")
@@ -163,10 +164,11 @@ module Reality
163
164
  rescue
164
165
  puts "Skipping whitespace cleanup: #{filename}"
165
166
  end
167
+ return '' if allow_empty && content.strip.length == 0
166
168
  content
167
169
  end
168
170
 
169
- def clean_dos_whitespace(filename, content, eofnl)
171
+ def clean_dos_whitespace(filename, content, eofnl, allow_empty)
170
172
  begin
171
173
  content.gsub!(/\r\n/, "\n")
172
174
  content.gsub!(/[ \t]+\n/, "\n")
@@ -176,6 +178,7 @@ module Reality
176
178
  rescue
177
179
  puts "Skipping dos whitespace cleanup: #{filename}"
178
180
  end
181
+ return '' if allow_empty && content.strip.length == 0
179
182
  content
180
183
  end
181
184
 
@@ -206,7 +209,8 @@ module Reality
206
209
  # Bazel defaults
207
210
  attributes.text_rule('.bazelrc')
208
211
  attributes.text_rule('WORKSPACE')
209
- attributes.text_rule('BUILD')
212
+ attributes.text_rule('BUILD', :allow_empty => true)
213
+ attributes.text_rule('BUILD.bazel', :allow_empty => true)
210
214
  attributes.text_rule('*.bzl')
211
215
 
212
216
  # Ruby defaults
@@ -150,6 +150,18 @@ TEXT
150
150
  end
151
151
  end
152
152
 
153
+ def test_allow_empty
154
+ dir = create_git_repo do
155
+ write_file('BUILD', "\n")
156
+ end
157
+ in_dir(dir) do
158
+ output = run_command("#{ZAPWHITE_BIN}", 2)
159
+ assert_equal "Fixing: .gitattributes\nFixing: BUILD\n", output
160
+ assert_equal "", IO.binread("#{dir}/BUILD")
161
+ assert_equal "# DO NOT EDIT: File is auto-generated\n* -text\nBUILD text allow_empty\n", IO.binread("#{dir}/.gitattributes")
162
+ end
163
+ end
164
+
153
165
  def test_generate_gitattributes_matches
154
166
  dir = create_git_repo do
155
167
  write_gitattributes_file(<<TEXT)
data/zapwhite.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zapwhite}
5
- s.version = '2.12.0'
5
+ s.version = '2.13.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zapwhite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitattributes