zapwhite 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/zapwhite +23 -0
- data/lib/reality/zapwhite.rb +7 -1
- data/test/reality/test_zapwhite.rb +86 -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: 81bcca5ce52c55d266fdfa3cffde9ce3cd270669
|
4
|
+
data.tar.gz: 9b2c1de397485ca1897e159fc5872dbd56e2ddfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72c6981d8c3bb449503bc2fad48f21d89c989f27d5cbe8ea0301ddb75409dee025ca69fcb4d441207e89039f74da1019712931beb7fb59f4a2edd30d746558a
|
7
|
+
data.tar.gz: de3cb47158d66835ae676bfabf4b8c4280a374aa9bdbad90994660de4791014cb2d111cb19cd52782ebae8fec8c7653bdefa39e5bf0d5c771beda9b7490fd009
|
data/bin/zapwhite
CHANGED
@@ -6,6 +6,7 @@ require 'bundler/setup'
|
|
6
6
|
require 'optparse'
|
7
7
|
require 'reality/zapwhite'
|
8
8
|
|
9
|
+
@verbose = false
|
9
10
|
@check_only = false
|
10
11
|
@generate_gitattributes = true
|
11
12
|
@exclude_patterns = []
|
@@ -33,6 +34,10 @@ OptionParser.new do |opts|
|
|
33
34
|
opts.on('-r', '--rule RULE', 'Additional rule(s) (a.k.a. lines) to add when generating .gitattributes file.') do |rule|
|
34
35
|
@rules << rule
|
35
36
|
end
|
37
|
+
|
38
|
+
opts.on('-v', '--verbose', 'Print additional information during operation.') do
|
39
|
+
@verbose = true
|
40
|
+
end
|
36
41
|
end.parse!
|
37
42
|
|
38
43
|
unless ARGV.empty?
|
@@ -51,4 +56,22 @@ unless @exclude_patterns.empty?
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
59
|
+
if @verbose
|
60
|
+
puts "Base Directory: #{@base_directory}"
|
61
|
+
puts "Check for violations or fix violations: #{runner.check_only? ? 'check' : 'fix'}"
|
62
|
+
puts "Generate .gitattributes file?: #{runner.generate_gitattributes?}"
|
63
|
+
unless runner.additional_gitattribute_rules.empty?
|
64
|
+
puts 'Additional .gitattribute rules:'
|
65
|
+
runner.additional_gitattribute_rules.each do |rule|
|
66
|
+
puts " * #{rule}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
unless runner.exclude_patterns.empty?
|
70
|
+
puts 'Exclude patterns:'
|
71
|
+
runner.exclude_patterns.each do |pattern|
|
72
|
+
puts " * #{pattern}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
54
77
|
exit runner.run
|
data/lib/reality/zapwhite.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
#
|
14
14
|
|
15
15
|
require 'reality/gitattributes'
|
16
|
+
require 'json'
|
16
17
|
|
17
18
|
module Reality
|
18
19
|
class Zapwhite
|
@@ -20,7 +21,7 @@ module Reality
|
|
20
21
|
def initialize(base_directory)
|
21
22
|
@base_directory = base_directory
|
22
23
|
@attributes = Reality::Git::Attributes.parse(@base_directory)
|
23
|
-
@exclude_patterns = %w(vendor/.* node_modules/.*)
|
24
|
+
@exclude_patterns = %w(vendor/.* node_modules/.*) + load_braid_mirrors
|
24
25
|
@check_only = false
|
25
26
|
@additional_gitattribute_rules = []
|
26
27
|
end
|
@@ -102,6 +103,11 @@ module Reality
|
|
102
103
|
|
103
104
|
private
|
104
105
|
|
106
|
+
def load_braid_mirrors
|
107
|
+
braid_file = "#{@base_directory}/.braids.json"
|
108
|
+
File.exist?(braid_file) ? JSON.parse(IO.read(braid_file)).keys : []
|
109
|
+
end
|
110
|
+
|
105
111
|
def generate_gitattributes!
|
106
112
|
attributes = Reality::Git::Attributes.new(@base_directory)
|
107
113
|
template = create_template_gitattributes
|
@@ -179,5 +179,91 @@ TEXT
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
+
def test_verbose_mode
|
183
|
+
dir = create_git_repo do
|
184
|
+
write_file('README.md', "Hello\n")
|
185
|
+
end
|
186
|
+
in_dir(dir) do
|
187
|
+
output = run_command("#{ZAPWHITE_BIN} --generate-gitattributes --rule '*.bin -diff' --rule '*.rxt text' --verbose", 1)
|
188
|
+
assert_equal <<OUTPUT, output
|
189
|
+
Base Directory: #{dir}
|
190
|
+
Check for violations or fix violations: fix
|
191
|
+
Generate .gitattributes file?: true
|
192
|
+
Additional .gitattribute rules:
|
193
|
+
* *.bin -diff
|
194
|
+
* *.rxt text
|
195
|
+
Exclude patterns:
|
196
|
+
* vendor/.*
|
197
|
+
* node_modules/.*
|
198
|
+
Fixing: .gitattributes
|
199
|
+
OUTPUT
|
200
|
+
end
|
201
|
+
end
|
182
202
|
|
203
|
+
def test_braids_are_added_to_excludes
|
204
|
+
dir = create_git_repo do
|
205
|
+
write_file('README.md', "Hello\n")
|
206
|
+
write_file('.braids.json',<<BRAIDS_JSON)
|
207
|
+
{
|
208
|
+
"vendor/docs/way_of_stock": {
|
209
|
+
"url": "https://github.com/stocksoftware/way_of_stock.git",
|
210
|
+
"branch": "master",
|
211
|
+
"revision": "0405926c5b4229e7d1f605a65603df64b5667f2d"
|
212
|
+
},
|
213
|
+
"vendor/tools/buildr_plus": {
|
214
|
+
"url": "https://github.com/realityforge/buildr_plus.git",
|
215
|
+
"branch": "master",
|
216
|
+
"revision": "4a4a0666871861de1ddc7581a02d6d656702fa6b"
|
217
|
+
},
|
218
|
+
"vendor/tools/dbt": {
|
219
|
+
"branch": "master",
|
220
|
+
"revision": "554139d3ea275bd54949b9504090c77e4d39ba65",
|
221
|
+
"url": "https://github.com/realityforge/dbt.git"
|
222
|
+
},
|
223
|
+
"vendor/tools/domgen": {
|
224
|
+
"branch": "master",
|
225
|
+
"revision": "1da8f5d43f9c84ac234c6354af8717bcfde03f88",
|
226
|
+
"url": "https://github.com/realityforge/domgen.git"
|
227
|
+
},
|
228
|
+
"vendor/tools/kinjen": {
|
229
|
+
"url": "https://github.com/realityforge/kinjen.git",
|
230
|
+
"branch": "master",
|
231
|
+
"revision": "34a962de77918bc1a76f1fcf8c92fe6721d5b524"
|
232
|
+
},
|
233
|
+
"vendor/tools/redfish": {
|
234
|
+
"url": "https://github.com/realityforge/redfish.git",
|
235
|
+
"branch": "master",
|
236
|
+
"revision": "5e6bb18009e682c09631e1234c955373735d27ab"
|
237
|
+
},
|
238
|
+
"vendor/tools/resgen": {
|
239
|
+
"url": "https://github.com/realityforge/resgen.git",
|
240
|
+
"branch": "master",
|
241
|
+
"revision": "631a5aa371d3c6f2a68c95e5da3ca8e16a6ee0c7"
|
242
|
+
}
|
243
|
+
}
|
244
|
+
BRAIDS_JSON
|
245
|
+
end
|
246
|
+
in_dir(dir) do
|
247
|
+
output = run_command("#{ZAPWHITE_BIN} --generate-gitattributes --rule '*.bin -diff' --rule '*.rxt text' --verbose", 1)
|
248
|
+
assert_equal <<OUTPUT, output
|
249
|
+
Base Directory: #{dir}
|
250
|
+
Check for violations or fix violations: fix
|
251
|
+
Generate .gitattributes file?: true
|
252
|
+
Additional .gitattribute rules:
|
253
|
+
* *.bin -diff
|
254
|
+
* *.rxt text
|
255
|
+
Exclude patterns:
|
256
|
+
* vendor/.*
|
257
|
+
* node_modules/.*
|
258
|
+
* vendor/docs/way_of_stock
|
259
|
+
* vendor/tools/buildr_plus
|
260
|
+
* vendor/tools/dbt
|
261
|
+
* vendor/tools/domgen
|
262
|
+
* vendor/tools/kinjen
|
263
|
+
* vendor/tools/redfish
|
264
|
+
* vendor/tools/resgen
|
265
|
+
Fixing: .gitattributes
|
266
|
+
OUTPUT
|
267
|
+
end
|
268
|
+
end
|
183
269
|
end
|
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.7.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: 2017-08-
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitattributes
|