json-merge 7.1.15 → 7.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/json/merge/provider.rb +80 -2
- data/lib/json/merge/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +12 -12
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89491deadad83570cf1cdc75e5bd1b38b961db15ed9d75baece541a5fd595821
|
|
4
|
+
data.tar.gz: e01828afce16e8a6427430e77d7360be38125d69438abbac3b3dc6d93ab932bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3dbfbd3820cae781ef47301837f4156f66b23c31c00dcc09d43c8121b09f62ff4bb1822537d19f32b6c5a921539a9f30401b94e71e7eabe9d85d25c7914ea36
|
|
7
|
+
data.tar.gz: 91a148b8deac41f8783e132dcf485f20a88ee0f0954aa94e8d88e1b6f2a44e3685bf51c82aa26836bef1f5fe1b4da8ab909be7a4f1e4380c01ee29ac9d927e2e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/json/merge/provider.rb
CHANGED
|
@@ -195,9 +195,41 @@ module Json
|
|
|
195
195
|
exact = render_exact_composite(request, decision)
|
|
196
196
|
return exact if exact
|
|
197
197
|
|
|
198
|
+
planned = render_planned_value(request, decision)
|
|
199
|
+
return planned if planned
|
|
200
|
+
|
|
198
201
|
composite_failure(request, 'JSON family renderers did not reproduce the planned three-way value.')
|
|
199
202
|
end
|
|
200
203
|
|
|
204
|
+
def render_planned_value(request, decision)
|
|
205
|
+
output = "#{JSON.pretty_generate(decision.value)}\n"
|
|
206
|
+
verification = verify_rendered(output, decision.value, request)
|
|
207
|
+
return unless verification[:semantic_match]
|
|
208
|
+
|
|
209
|
+
rendered = render_plan(
|
|
210
|
+
request,
|
|
211
|
+
[
|
|
212
|
+
Ast::Merge::SourceRender::SynthesizedFragment.new(
|
|
213
|
+
content: output,
|
|
214
|
+
reason: :planned_value_emission,
|
|
215
|
+
producer: provider_id
|
|
216
|
+
)
|
|
217
|
+
]
|
|
218
|
+
)
|
|
219
|
+
{
|
|
220
|
+
output: rendered.content,
|
|
221
|
+
render_report: render_report(rendered, strategy: :planned_value_emission),
|
|
222
|
+
fallbacks: [
|
|
223
|
+
{
|
|
224
|
+
from: :exact_owner_composite,
|
|
225
|
+
to: :planned_value_emission,
|
|
226
|
+
reason: :owner_not_whole_line_addressable
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
verification: verification
|
|
230
|
+
}
|
|
231
|
+
end
|
|
232
|
+
|
|
201
233
|
def verified_family_composite(candidate, request, decision)
|
|
202
234
|
return unless candidate[:ok]
|
|
203
235
|
|
|
@@ -275,8 +307,7 @@ module Json
|
|
|
275
307
|
replacements.sort_by { |item| item.fetch(:ours).start_line }.each do |item|
|
|
276
308
|
ours_range = item.fetch(:ours)
|
|
277
309
|
fragments << source_range_fragment(:ours, cursor, ours_range.start_line - 1) if cursor < ours_range.start_line
|
|
278
|
-
|
|
279
|
-
fragments << source_range_fragment(:theirs, theirs_range.start_line, theirs_range.end_line) if theirs_range
|
|
310
|
+
fragments << theirs_replacement_fragment(request, item) if item[:theirs]
|
|
280
311
|
cursor = ours_range.end_line + 1
|
|
281
312
|
end
|
|
282
313
|
final_line = request.fetch(:ours_source).lines.length
|
|
@@ -284,6 +315,53 @@ module Json
|
|
|
284
315
|
fragments
|
|
285
316
|
end
|
|
286
317
|
|
|
318
|
+
# A theirs pair spliced into ours' object must carry the trailing comma
|
|
319
|
+
# of the position it lands in: a pair copied from the end of theirs'
|
|
320
|
+
# object has no comma, but the ours pair it replaces may be followed by
|
|
321
|
+
# more pairs (and vice versa). Copy verbatim when the comma context
|
|
322
|
+
# already matches; synthesize comma-aligned content otherwise.
|
|
323
|
+
def theirs_replacement_fragment(request, item)
|
|
324
|
+
theirs_range = item.fetch(:theirs)
|
|
325
|
+
ours_range = item.fetch(:ours)
|
|
326
|
+
ours_lines = request.fetch(:ours_source).lines[(ours_range.start_line - 1)..(ours_range.end_line - 1)]
|
|
327
|
+
theirs_lines = request.fetch(:theirs_source).lines[(theirs_range.start_line - 1)..(theirs_range.end_line - 1)]
|
|
328
|
+
if trailing_comma?(ours_lines) == trailing_comma?(theirs_lines)
|
|
329
|
+
return source_range_fragment(:theirs, theirs_range.start_line, theirs_range.end_line)
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
Ast::Merge::SourceRender::SynthesizedFragment.new(
|
|
333
|
+
content: comma_aligned_lines(theirs_lines, with_comma: trailing_comma?(ours_lines)),
|
|
334
|
+
reason: :comma_context_alignment,
|
|
335
|
+
producer: provider_id,
|
|
336
|
+
metadata: { source_role: :theirs, copied_source: true }
|
|
337
|
+
)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def trailing_comma?(lines)
|
|
341
|
+
lines.last.to_s.rstrip.end_with?(',')
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def comma_aligned_lines(lines, with_comma:)
|
|
345
|
+
adjusted = lines.dup
|
|
346
|
+
last = adjusted.fetch(-1)
|
|
347
|
+
newline =
|
|
348
|
+
if last.end_with?("\r\n")
|
|
349
|
+
"\r\n"
|
|
350
|
+
elsif last.end_with?("\n")
|
|
351
|
+
"\n"
|
|
352
|
+
else
|
|
353
|
+
''
|
|
354
|
+
end
|
|
355
|
+
body = last.delete_suffix("\r\n").delete_suffix("\n")
|
|
356
|
+
adjusted[-1] =
|
|
357
|
+
if with_comma
|
|
358
|
+
"#{body.rstrip},#{newline}"
|
|
359
|
+
else
|
|
360
|
+
"#{body.sub(/,\s*\z/, '')}#{newline}"
|
|
361
|
+
end
|
|
362
|
+
adjusted.join
|
|
363
|
+
end
|
|
364
|
+
|
|
287
365
|
def render_conflict(request, decision)
|
|
288
366
|
localized = localized_conflict_plan(request, decision)
|
|
289
367
|
return localized if localized
|
data/lib/json/merge/version.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Json
|
|
|
5
5
|
# Version namespace for this gem.
|
|
6
6
|
module Version
|
|
7
7
|
# Current gem version.
|
|
8
|
-
VERSION = '7.1.
|
|
8
|
+
VERSION = '7.1.16'
|
|
9
9
|
end
|
|
10
10
|
# Current gem version exposed at the traditional constant location.
|
|
11
11
|
VERSION = Version::VERSION # Traditional Constant Location
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: json-merge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.1.
|
|
4
|
+
version: 7.1.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -43,28 +43,28 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - '='
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 7.1.
|
|
46
|
+
version: 7.1.16
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - '='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 7.1.
|
|
53
|
+
version: 7.1.16
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: tree_haver
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - '='
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 7.1.
|
|
60
|
+
version: 7.1.16
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - '='
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 7.1.
|
|
67
|
+
version: 7.1.16
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: version_gem
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,7 +94,7 @@ dependencies:
|
|
|
94
94
|
version: '3.1'
|
|
95
95
|
- - ">="
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: 3.1.
|
|
97
|
+
version: 3.1.21
|
|
98
98
|
type: :development
|
|
99
99
|
prerelease: false
|
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -104,7 +104,7 @@ dependencies:
|
|
|
104
104
|
version: '3.1'
|
|
105
105
|
- - ">="
|
|
106
106
|
- !ruby/object:Gem::Version
|
|
107
|
-
version: 3.1.
|
|
107
|
+
version: 3.1.21
|
|
108
108
|
- !ruby/object:Gem::Dependency
|
|
109
109
|
name: bundler-audit
|
|
110
110
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -182,7 +182,7 @@ dependencies:
|
|
|
182
182
|
version: '3.2'
|
|
183
183
|
- - ">="
|
|
184
184
|
- !ruby/object:Gem::Version
|
|
185
|
-
version: 3.2.
|
|
185
|
+
version: 3.2.6
|
|
186
186
|
type: :development
|
|
187
187
|
prerelease: false
|
|
188
188
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -192,7 +192,7 @@ dependencies:
|
|
|
192
192
|
version: '3.2'
|
|
193
193
|
- - ">="
|
|
194
194
|
- !ruby/object:Gem::Version
|
|
195
|
-
version: 3.2.
|
|
195
|
+
version: 3.2.6
|
|
196
196
|
- !ruby/object:Gem::Dependency
|
|
197
197
|
name: kettle-test
|
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -322,10 +322,10 @@ licenses:
|
|
|
322
322
|
- PolyForm-Small-Business-1.0.0
|
|
323
323
|
metadata:
|
|
324
324
|
homepage_uri: https://structuredmerge.org
|
|
325
|
-
source_code_uri: https://github.com/structuredmerge/structuredmerge-ruby/tree/v7.1.
|
|
326
|
-
changelog_uri: https://github.com/structuredmerge/structuredmerge-ruby/blob/v7.1.
|
|
325
|
+
source_code_uri: https://github.com/structuredmerge/structuredmerge-ruby/tree/v7.1.16
|
|
326
|
+
changelog_uri: https://github.com/structuredmerge/structuredmerge-ruby/blob/v7.1.16/CHANGELOG.md
|
|
327
327
|
bug_tracker_uri: https://github.com/structuredmerge/structuredmerge-ruby/issues
|
|
328
|
-
documentation_uri: https://www.rubydoc.info/gems/json-merge/7.1.
|
|
328
|
+
documentation_uri: https://www.rubydoc.info/gems/json-merge/7.1.16
|
|
329
329
|
funding_uri: https://github.com/sponsors/pboling
|
|
330
330
|
wiki_uri: https://github.com/structuredmerge/structuredmerge-ruby/wiki
|
|
331
331
|
news_uri: https://www.railsbling.com/tags/json-merge
|
metadata.gz.sig
CHANGED
|
Binary file
|