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 +4 -4
- data/lib/reality/zapwhite.rb +9 -5
- data/test/reality/test_zapwhite.rb +12 -0
- data/zapwhite.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8435f3678c780c9f8c20c3f01fb6e10593589090
|
4
|
+
data.tar.gz: 51ec2d14cba5a0d3b52e41a7c2115cd68ddfdef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a250a0c649f15cac854399eb8ee4a53a8a750065d2f2bbe79a2ad99d285d3e21ecbe66a1d3a350255f99aca653d2675db3d454e070652118381624827a117a2e
|
7
|
+
data.tar.gz: 63566b1ce95451e78a39cbcb1ba33f550dc231f22c12802e6d817d456ffc1c5ec00d8f51f9577d5312a05c2c34226460d2da026aa7dcae6f4c01bdfe9b6db1d2
|
data/lib/reality/zapwhite.rb
CHANGED
@@ -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
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.
|
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-
|
11
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitattributes
|