prism-merge 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d39e0e854397866379ca524e10088fdaa4d31029358962472fec0c174e0780c4
4
- data.tar.gz: 2805f8137670b5660f510cc6ca119447ac3e90967da0b0b09cc5cd7ca621fd51
3
+ metadata.gz: f43aef831e7dd032d7607b541bcc542cb2899514150346632084148b167dc0a5
4
+ data.tar.gz: 104a80156b7b15d02c8b7f5b237998a4d4c225f22f7d108c46642ddea7e6c51e
5
5
  SHA512:
6
- metadata.gz: dcc00673756cdb1619b0189b1dfb0a8048b7035c4eee228b46cf9ccc5d215211bb7d39a9721a40027e63f8507b75646643240ddab107004658f0686a9395f30d
7
- data.tar.gz: 4c7e388e010b061286dc2e45cc90b482cec283893b9d3862f5153faaebc8b6250207b7952f8ee6463f1e012803e9774f77a4d4f1800c76e4d51697963b977e76
6
+ metadata.gz: 425c404b3e0396b5db166b0c4e2fca941af3f6b6d0727ece8b0cd19bc60f9901883d587dee4a90c43356b6fa4b6b98d841fbf791785fb410662d72df0e7c5d2b
7
+ data.tar.gz: eb666082134afb97479cd8dd020baa6b8ef45b489d0b8c3a4df8ad6e19e8100d53cba60d48c930d7ed43ce8830bf2ec5b309fc432a24dfb5440c1fa9eb9a9b7f
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,29 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [2.0.2] - 2026-02-22
34
+
35
+ - TAG: [v2.0.2][2.0.2t]
36
+ - COVERAGE: 98.80% -- 823/833 lines in 12 files
37
+ - BRANCH COVERAGE: 85.61% -- 452/528 branches in 12 files
38
+ - 93.51% documented
39
+
40
+ ### Fixed
41
+
42
+ - Fix node duplication when merging files with inline trailing comments (e.g.,
43
+ gemspec `add_dependency` lines with `# ruby >= 3.2.0`). `add_node_to_result`
44
+ output the full source line (which already includes inline comments via
45
+ `analysis.line_at`), then also iterated `trailing_comments` and re-emitted any
46
+ comment on the same line — duplicating the entire line. Now skips trailing
47
+ comments whose `start_line` falls within the node's own line range. This was the
48
+ root cause of every `add_dependency` / `add_development_dependency` being
49
+ duplicated in gemspec and gemfile merges when inline comments were present.
50
+ - Prevent potential double-wrapping in `merge_node_body_recursively` — store the
51
+ raw (unwrapped) `signature_generator` as `@raw_signature_generator` and pass it
52
+ (instead of the already-effective generator) to inner `SmartMerger` instances.
53
+ This ensures `build_effective_signature_generator` wraps it only once when
54
+ `node_typing` is also configured.
55
+
33
56
  ## [2.0.1] - 2026-02-22
34
57
 
35
58
  - TAG: [v2.0.1][2.0.1t]
@@ -315,7 +338,9 @@ Please file a bug if you notice a violation of semantic versioning.
315
338
 
316
339
  - Initial release
317
340
 
318
- [Unreleased]: https://github.com/kettle-rb/prism-merge/compare/v2.0.1...HEAD
341
+ [Unreleased]: https://github.com/kettle-rb/prism-merge/compare/v2.0.2...HEAD
342
+ [2.0.2]: https://github.com/kettle-rb/prism-merge/compare/v2.0.1...v2.0.2
343
+ [2.0.2t]: https://github.com/kettle-rb/prism-merge/releases/tag/v2.0.2
319
344
  [2.0.1]: https://github.com/kettle-rb/prism-merge/compare/v2.0.0...v2.0.1
320
345
  [2.0.1t]: https://github.com/kettle-rb/prism-merge/releases/tag/v2.0.1
321
346
  [2.0.0]: https://github.com/kettle-rb/prism-merge/compare/v1.1.6...v2.0.0
data/README.md CHANGED
@@ -1564,7 +1564,7 @@ Thanks for RTFM. ☺️
1564
1564
  [📌gitmoji]: https://gitmoji.dev
1565
1565
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
1566
1566
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
1567
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.830-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1567
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.833-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1568
1568
  [🔐security]: SECURITY.md
1569
1569
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
1570
1570
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -94,6 +94,11 @@ module Prism
94
94
  @current_depth = current_depth
95
95
  @text_merger_options = text_merger_options
96
96
 
97
+ # Store the raw (unwrapped) signature_generator so that
98
+ # merge_node_body_recursively can pass it to inner SmartMergers
99
+ # without double-wrapping.
100
+ @raw_signature_generator = signature_generator
101
+
97
102
  # Wrap signature_generator to include node_typing processing
98
103
  effective_signature_generator = build_effective_signature_generator(signature_generator, node_typing)
99
104
 
@@ -751,10 +756,15 @@ module Prism
751
756
  end
752
757
  end
753
758
 
754
- # Add trailing comments attached to the node (e.g., end-of-file comments)
759
+ # Add trailing comments attached to the node (e.g., end-of-file comments).
760
+ # Skip comments on the same line as the node — inline comments are already
761
+ # included when we output the node's source lines via analysis.line_at.
755
762
  trailing_comments = node.location.respond_to?(:trailing_comments) ? node.location.trailing_comments : []
763
+ node_line_range = node.location.start_line..node.location.end_line
756
764
  trailing_comments.each do |comment|
757
765
  line_num = comment.location.start_line
766
+ next if node_line_range.cover?(line_num)
767
+
758
768
  line = analysis.line_at(line_num)&.chomp || comment.slice.rstrip
759
769
 
760
770
  if source == :template
@@ -875,11 +885,15 @@ module Prism
875
885
  template_body = extract_node_body(actual_template, @template_analysis)
876
886
  dest_body = extract_node_body(actual_dest, @dest_analysis)
877
887
 
878
- # Recursively merge the bodies with incremented depth
888
+ # Recursively merge the bodies with incremented depth.
889
+ # Use the raw (unwrapped) signature_generator so the inner SmartMerger
890
+ # can wrap it fresh via build_effective_signature_generator. Using the
891
+ # already-effective generator would cause double-wrapping when
892
+ # node_typing is also passed, making is_a? checks fail.
879
893
  body_merger = SmartMerger.new(
880
894
  template_body,
881
895
  dest_body,
882
- signature_generator: @template_analysis.instance_variable_get(:@signature_generator),
896
+ signature_generator: @raw_signature_generator,
883
897
  preference: @preference,
884
898
  add_template_only_nodes: @add_template_only_nodes,
885
899
  freeze_token: @freeze_token,
@@ -5,7 +5,7 @@ module Prism
5
5
  # Version information for Prism::Merge
6
6
  module Version
7
7
  # Current version of the prism-merge gem
8
- VERSION = "2.0.1"
8
+ VERSION = "2.0.2"
9
9
  end
10
10
  VERSION = Version::VERSION # traditional location
11
11
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism-merge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -314,10 +314,10 @@ licenses:
314
314
  - MIT
315
315
  metadata:
316
316
  homepage_uri: https://prism-merge.galtzo.com/
317
- source_code_uri: https://github.com/kettle-rb/prism-merge/tree/v2.0.1
318
- changelog_uri: https://github.com/kettle-rb/prism-merge/blob/v2.0.1/CHANGELOG.md
317
+ source_code_uri: https://github.com/kettle-rb/prism-merge/tree/v2.0.2
318
+ changelog_uri: https://github.com/kettle-rb/prism-merge/blob/v2.0.2/CHANGELOG.md
319
319
  bug_tracker_uri: https://github.com/kettle-rb/prism-merge/issues
320
- documentation_uri: https://www.rubydoc.info/gems/prism-merge/2.0.1
320
+ documentation_uri: https://www.rubydoc.info/gems/prism-merge/2.0.2
321
321
  funding_uri: https://github.com/sponsors/pboling
322
322
  wiki_uri: https://github.com/kettle-rb/prism-merge/wiki
323
323
  news_uri: https://www.railsbling.com/tags/prism-merge
metadata.gz.sig CHANGED
Binary file