prism-merge 1.1.2 → 1.1.3

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: a67c080bc59cb7303a0f2d3da1c3e5518cf57f20bc1e5b0a43e8e003db155209
4
- data.tar.gz: 9ddc4c529df3107414dc7c325f230d9224a30d3b828053a4ef76f9c38d05ce1b
3
+ metadata.gz: 1a36b93898e34e1e7f7b895b191ccdd3a84b1631501b3274de6a239982f2336e
4
+ data.tar.gz: 14abab7edea6adccdbdddfaf1e00fa42e2fc29f69b6c5c28657d6341dba112f5
5
5
  SHA512:
6
- metadata.gz: 6a88190811477660b57af41696a567ee899a76f04b918aa98d8e4c0ea45d5b0dca9b3eceb2abb8564dbb3912abdc35bf89b4a3736000b17d583d869e2f688fbd
7
- data.tar.gz: 4cd9b298503649db46812dda1cfd2a04f37c0db776ff5dcc684ebe199fd81f6e469c13ed27ac375c7d23c6ae9e14a00afa2db5c8f8698a94ed080db595d8526d
6
+ metadata.gz: dd82df79c0775bb1d096971350b1f313331f7dbb071d0dae22a2c75593f8f797e8b34236c07e4706a35032276657bc763e4bbb0b7434e5949533b3585055b1b2
7
+ data.tar.gz: eaf27e5dbb8a47ab74003978f4fff007d1dc14c98fe65b11f94e931360b3eb672dd63c5e6b815247a60413da0208f5be1797aeda6af48b8c946f2056e13a2cdc
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,17 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [1.1.3] - 2025-12-04
34
+
35
+ - TAG: [v1.1.3][1.1.3t]
36
+ - COVERAGE: 96.71% -- 881/911 lines in 9 files
37
+ - BRANCH COVERAGE: 82.86% -- 348/420 branches in 9 files
38
+ - 100.00% documented
39
+
40
+ ### Fixed
41
+
42
+ - **Fixed indentation loss** when adding nodes to merge result - the `add_node` method was using `node.slice` which loses leading indentation. Now uses `source_analysis.line_at` to get full lines from the source file, preserving original indentation.
43
+
33
44
  ## [1.1.2] - 2025-12-04
34
45
 
35
46
  - TAG: [v1.1.2][1.1.2t]
@@ -171,7 +182,9 @@ Please file a bug if you notice a violation of semantic versioning.
171
182
 
172
183
  - Initial release
173
184
 
174
- [Unreleased]: https://github.com/kettle-rb/prism-merge/compare/v1.1.2...HEAD
185
+ [Unreleased]: https://github.com/kettle-rb/prism-merge/compare/v1.1.3...HEAD
186
+ [1.1.3]: https://github.com/kettle-rb/prism-merge/compare/v1.1.2...v1.1.3
187
+ [1.1.3t]: https://github.com/kettle-rb/prism-merge/releases/tag/v1.1.3
175
188
  [1.1.2]: https://github.com/kettle-rb/prism-merge/compare/v1.1.1...v1.1.2
176
189
  [1.1.2t]: https://github.com/kettle-rb/prism-merge/releases/tag/v1.1.2
177
190
  [1.1.1]: https://github.com/kettle-rb/prism-merge/compare/v1.1.0...v1.1.1
data/README.md CHANGED
@@ -1134,7 +1134,7 @@ Thanks for RTFM. ☺️
1134
1134
  [📌gitmoji]: https://gitmoji.dev
1135
1135
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
1136
1136
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
1137
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.898-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1137
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.911-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1138
1138
  [🔐security]: SECURITY.md
1139
1139
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
1140
1140
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -73,15 +73,21 @@ module Prism
73
73
  # @param node_info [Hash] Node information from FileAnalysis
74
74
  # @param decision [Symbol] Merge decision
75
75
  # @param source [Symbol] :template or :destination
76
- # @param source_analysis [FileAnalysis] Source file analysis (unused but kept for compatibility)
76
+ # @param source_analysis [FileAnalysis] Source file analysis for preserving indentation
77
77
  def add_node(node_info, decision:, source:, source_analysis: nil)
78
78
  node = node_info[:node]
79
79
  start_line = node.location.start_line
80
+ end_line = node.location.end_line
80
81
 
81
82
  # Add leading comments
82
83
  node_info[:leading_comments].each do |comment|
83
- line = comment.slice.rstrip
84
84
  comment_line = comment.location.start_line
85
+ # Use source_analysis to get full line with indentation if available
86
+ line = if source_analysis
87
+ source_analysis.line_at(comment_line)&.chomp || comment.slice.rstrip
88
+ else
89
+ comment.slice.rstrip
90
+ end
85
91
  if source == :template
86
92
  add_line(line, decision: decision, template_line: comment_line)
87
93
  else
@@ -89,27 +95,49 @@ module Prism
89
95
  end
90
96
  end
91
97
 
92
- # Add node source
93
- node_source = node.slice
94
- node_lines = node_source.lines(chomp: true)
95
-
96
- # Handle inline comments
97
- inline_comments = node_info[:inline_comments]
98
- if inline_comments.any?
99
- # Inline comments are on the last line
100
- last_idx = node_lines.length - 1
101
- if last_idx >= 0
102
- inline_text = inline_comments.map { |c| c.slice.strip }.join(" ")
103
- node_lines[last_idx] = node_lines[last_idx].rstrip + " " + inline_text
98
+ # Add node source lines
99
+ # Use source_analysis.line_at to preserve original indentation
100
+ if source_analysis
101
+ # Get full lines from source to preserve indentation
102
+ inline_comments = node_info[:inline_comments]
103
+ (start_line..end_line).each do |line_num|
104
+ line = source_analysis.line_at(line_num)&.chomp || ""
105
+
106
+ # Handle inline comments on the last line
107
+ if line_num == end_line && inline_comments.any?
108
+ inline_text = inline_comments.map { |c| c.slice.strip }.join(" ")
109
+ line = line.rstrip + " " + inline_text
110
+ end
111
+
112
+ if source == :template
113
+ add_line(line, decision: decision, template_line: line_num)
114
+ else
115
+ add_line(line, decision: decision, dest_line: line_num)
116
+ end
117
+ end
118
+ else
119
+ # Fallback: use node.slice (loses leading indentation)
120
+ node_source = node.slice
121
+ node_lines = node_source.lines(chomp: true)
122
+
123
+ # Handle inline comments
124
+ inline_comments = node_info[:inline_comments]
125
+ if inline_comments.any?
126
+ # Inline comments are on the last line
127
+ last_idx = node_lines.length - 1
128
+ if last_idx >= 0
129
+ inline_text = inline_comments.map { |c| c.slice.strip }.join(" ")
130
+ node_lines[last_idx] = node_lines[last_idx].rstrip + " " + inline_text
131
+ end
104
132
  end
105
- end
106
133
 
107
- node_lines.each_with_index do |line, idx|
108
- line_num = start_line + idx
109
- if source == :template
110
- add_line(line, decision: decision, template_line: line_num)
111
- else
112
- add_line(line, decision: decision, dest_line: line_num)
134
+ node_lines.each_with_index do |line, idx|
135
+ line_num = start_line + idx
136
+ if source == :template
137
+ add_line(line, decision: decision, template_line: line_num)
138
+ else
139
+ add_line(line, decision: decision, dest_line: line_num)
140
+ end
113
141
  end
114
142
  end
115
143
  end
@@ -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 = "1.1.2"
8
+ VERSION = "1.1.3"
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: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -265,10 +265,10 @@ licenses:
265
265
  - MIT
266
266
  metadata:
267
267
  homepage_uri: https://prism-merge.galtzo.com/
268
- source_code_uri: https://github.com/kettle-rb/prism-merge/tree/v1.1.2
269
- changelog_uri: https://github.com/kettle-rb/prism-merge/blob/v1.1.2/CHANGELOG.md
268
+ source_code_uri: https://github.com/kettle-rb/prism-merge/tree/v1.1.3
269
+ changelog_uri: https://github.com/kettle-rb/prism-merge/blob/v1.1.3/CHANGELOG.md
270
270
  bug_tracker_uri: https://github.com/kettle-rb/prism-merge/issues
271
- documentation_uri: https://www.rubydoc.info/gems/prism-merge/1.1.2
271
+ documentation_uri: https://www.rubydoc.info/gems/prism-merge/1.1.3
272
272
  funding_uri: https://github.com/sponsors/pboling
273
273
  wiki_uri: https://github.com/kettle-rb/prism-merge/wiki
274
274
  news_uri: https://www.railsbling.com/tags/prism-merge
metadata.gz.sig CHANGED
Binary file