octocatalog-diff 1.0.1 → 1.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a6057ffec45d60dbe793f5b81170c1d00b7d1af
|
4
|
+
data.tar.gz: 158d57d91c2d57d3f796732b814f85394346f553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ea4c161583582db60e6e89349ff4c2e2153080fc27a01b2b7a5f01af3ef920d52b69a1515c7f4c51329036c7949aea5ad7d97221e6a987a765240f4b5cc05e8
|
7
|
+
data.tar.gz: fbccb8d52fe1346f880584d95405b744e119528686846c7dfcd36d0e7087273c27c5703d90ad5a985b7fd1e6ef558e9b2b34c677d4508f52ecb791314166cb1b
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/doc/CHANGELOG.md
CHANGED
@@ -8,6 +8,13 @@
|
|
8
8
|
</tr>
|
9
9
|
</thead><tbody>
|
10
10
|
<tr valign=top>
|
11
|
+
<td>1.0.2</td>
|
12
|
+
<td>2017-03-08</td>
|
13
|
+
<td>
|
14
|
+
<li><a href="https://github.com/github/octocatalog-diff/pull/91">#91</a>: `--no-truncate-details` option</li>
|
15
|
+
</td>
|
16
|
+
</tr>
|
17
|
+
<tr valign=top>
|
11
18
|
<td>1.0.1</td>
|
12
19
|
<td>2017-02-14</td>
|
13
20
|
<td>
|
data/doc/optionsref.md
CHANGED
@@ -59,6 +59,7 @@ Usage: octocatalog-diff [command line options]
|
|
59
59
|
--from-enc PATH Path to ENC script (for the from catalog only)
|
60
60
|
--to-enc PATH Path to ENC script (for the to catalog only)
|
61
61
|
--[no-]display-detail-add Display parameters and other details for added resources
|
62
|
+
--[no-]truncate-details Truncate details with --display-detail-add
|
62
63
|
--no-header Do not print a header
|
63
64
|
--default-header Print default header with output
|
64
65
|
--header STRING Specify header for output
|
@@ -1092,6 +1093,21 @@ These files must exist and be in Puppet catalog format. (<a href="../lib/octocat
|
|
1092
1093
|
</td>
|
1093
1094
|
</tr>
|
1094
1095
|
|
1096
|
+
<tr>
|
1097
|
+
<td valign=top>
|
1098
|
+
<pre><code>--truncate-details
|
1099
|
+
--no-truncate-details </code></pre>
|
1100
|
+
</td>
|
1101
|
+
<td valign=top>
|
1102
|
+
Truncate details with --display-detail-add
|
1103
|
+
</td>
|
1104
|
+
<td valign=top>
|
1105
|
+
When using `--display-detail-add` by default the details of any field will be truncated
|
1106
|
+
at 80 characters. Specify `--no-truncate-details` to display the full output. This option
|
1107
|
+
has no effect when `--display-detail-add` is not used. (<a href="../lib/octocatalog-diff/cli/options/truncate_details.rb">truncate_details.rb</a>)
|
1108
|
+
</td>
|
1109
|
+
</tr>
|
1110
|
+
|
1095
1111
|
<tr>
|
1096
1112
|
<td valign=top>
|
1097
1113
|
<pre><code>--validate-references
|
@@ -168,13 +168,14 @@ module OctocatalogDiff
|
|
168
168
|
result = []
|
169
169
|
add_source_file_line_info(item: item, result: result, new_loc: new_loc, options: options, logger: logger)
|
170
170
|
if options[:display_detail_add] && diff.key?('parameters')
|
171
|
+
limit = options.fetch(:truncate_details, true) ? 80 : nil
|
171
172
|
result << "+ #{item} =>".green
|
172
173
|
result << ' parameters =>'.green
|
173
174
|
result.concat(
|
174
175
|
diff_two_hashes_with_diffy(
|
175
176
|
depth: 1,
|
176
177
|
hash2: Hash[diff['parameters'].sort], # Should work with somewhat older rubies too
|
177
|
-
limit:
|
178
|
+
limit: limit,
|
178
179
|
strip_diff: true
|
179
180
|
).map(&:green)
|
180
181
|
)
|
@@ -326,7 +327,7 @@ module OctocatalogDiff
|
|
326
327
|
# @param depth [Fixnum] Depth, for correct indentation
|
327
328
|
# @param limit [Fixnum] Maximum string length
|
328
329
|
# @param strip_diff [Boolean] Strip leading +/-/" "
|
329
|
-
# @return Array<String> Displayable result
|
330
|
+
# @return [Array<String>] Displayable result
|
330
331
|
def self.diff_two_hashes_with_diffy(opts = {})
|
331
332
|
depth = opts.fetch(:depth, 0)
|
332
333
|
hash1 = opts.fetch(:hash1, {})
|
@@ -334,6 +335,9 @@ module OctocatalogDiff
|
|
334
335
|
limit = opts[:limit]
|
335
336
|
strip_diff = opts.fetch(:strip_diff, false)
|
336
337
|
|
338
|
+
# Special case: addition only, no truncation
|
339
|
+
return addition_only_no_truncation(depth, hash2) if hash1 == {} && limit.nil?
|
340
|
+
|
337
341
|
json_old = stringify_for_diffy(hash1)
|
338
342
|
json_new = stringify_for_diffy(hash2)
|
339
343
|
|
@@ -353,6 +357,30 @@ module OctocatalogDiff
|
|
353
357
|
end
|
354
358
|
end
|
355
359
|
|
360
|
+
# Special case: addition only, no truncation
|
361
|
+
# @param depth [Fixnum] Depth, for correct indentation
|
362
|
+
# @param hash [Hash] Added object
|
363
|
+
# @return [Array<String>] Displayable result
|
364
|
+
def self.addition_only_no_truncation(depth, hash)
|
365
|
+
result = []
|
366
|
+
|
367
|
+
# Single line strings
|
368
|
+
hash.keys.sort.map do |key|
|
369
|
+
next if hash[key] =~ /\n/
|
370
|
+
result << left_pad(2 * depth + 4, [key.inspect, ': ', hash[key].inspect].join('')).green
|
371
|
+
end
|
372
|
+
|
373
|
+
# Multi-line strings
|
374
|
+
hash.keys.sort.map do |key|
|
375
|
+
next if hash[key] !~ /\n/
|
376
|
+
result << left_pad(2 * depth + 4, [key.inspect, ': >>>'].join('')).green
|
377
|
+
result.concat hash[key].split(/\n/).map(&:green)
|
378
|
+
result << '<<<'.green
|
379
|
+
end
|
380
|
+
|
381
|
+
result
|
382
|
+
end
|
383
|
+
|
356
384
|
# Limit length of a string
|
357
385
|
# @param str [String] String
|
358
386
|
# @param limit [Fixnum] Limit (0=unlimited)
|
@@ -37,6 +37,7 @@ module OctocatalogDiff
|
|
37
37
|
opts[:compilation_from_dir] = options[:compilation_from_dir] || nil
|
38
38
|
opts[:compilation_to_dir] = options[:compilation_to_dir] || nil
|
39
39
|
opts[:display_detail_add] = options.fetch(:display_detail_add, false)
|
40
|
+
opts[:truncate_details] = options.fetch(:truncate_details, true)
|
40
41
|
opts[:display_datatype_changes] = options.fetch(:display_datatype_changes, false)
|
41
42
|
|
42
43
|
# Call appropriate display method
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# When using `--display-detail-add` by default the details of any field will be truncated
|
4
|
+
# at 80 characters. Specify `--no-truncate-details` to display the full output. This option
|
5
|
+
# has no effect when `--display-detail-add` is not used.
|
6
|
+
# @param parser [OptionParser object] The OptionParser argument
|
7
|
+
# @param options [Hash] Options hash being constructed; this is modified in this method.
|
8
|
+
OctocatalogDiff::Cli::Options::Option.newoption(:truncate_details) do
|
9
|
+
has_weight 251
|
10
|
+
|
11
|
+
def parse(parser, options)
|
12
|
+
parser.on('--[no-]truncate-details', 'Truncate details with --display-detail-add') do |x|
|
13
|
+
options[:truncate_details] = x
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octocatalog-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diffy
|
@@ -381,6 +381,7 @@ files:
|
|
381
381
|
- lib/octocatalog-diff/cli/options/storeconfigs.rb
|
382
382
|
- lib/octocatalog-diff/cli/options/suppress_absent_file_details.rb
|
383
383
|
- lib/octocatalog-diff/cli/options/to_from_branch.rb
|
384
|
+
- lib/octocatalog-diff/cli/options/truncate_details.rb
|
384
385
|
- lib/octocatalog-diff/cli/options/validate_references.rb
|
385
386
|
- lib/octocatalog-diff/cli/printer.rb
|
386
387
|
- lib/octocatalog-diff/errors.rb
|