kou commented on code in PR #39215:
URL: https://github.com/apache/arrow/pull/39215#discussion_r1442171969
##########
dev/release/test-helper.rb:
##########
@@ -83,15 +83,60 @@ def parse_patch(patch)
when /\A@@/
in_hunk = true
diffs.last[:hunks] << []
- when /\A[-+]/
+ when /\A-/
next unless in_hunk
diffs.last[:hunks].last << line.chomp
+ when /\A\+/
+ next unless in_hunk
+ diffs.last[:hunks].last <<
normalize_added_line(line.chomp)
end
end
diffs.sort_by do |diff|
diff[:path]
end
end
+
+ def generate_hunks(lines)
+ git_diff_context = 3 # The default of Git's diff.context
+ max_lines_for_same_hunk = git_diff_context * 2 + 1
+ previous_i = nil
+ grouped_change_blocks = []
+ lines.each_with_index do |line, i|
+ deleted, added = yield(line)
+ next if deleted.nil? and added.nil?
+ if previous_i.nil? or (i - previous_i) > max_lines_for_same_hunk
+ grouped_change_blocks << []
+ end
+ if i - 1 != previous_i
+ grouped_change_blocks.last << []
+ end
+ grouped_change_blocks.last.last << [deleted, added]
+ previous_i = i
+ end
+ grouped_change_blocks.collect do |change_blocks|
+ hunk = []
+ change_blocks.each do |continuous_changes|
+ continuous_changes.each do |deleted, _|
+ hunk << "-#{deleted}" if deleted
+ end
+ continuous_changes.each do |_, added|
+ hunk << "+#{added}" if added
+ end
+ end
+ hunk
+ end
+ end
+
+ def normalize_pom_xml_output_timestamp(line)
+ line.gsub(/<project\.build\.outputTimestamp>.+?</) do
+ "<project.build.outputTimestamp>2023-12-13T00:00:00Z<"
+ end
+ end
+
+ def normalize_added_line(line)
+ normalize_pom_xml_output_timestamp(line)
+ end
+
Review Comment:
```suggestion
```
##########
dev/release/test-helper.rb:
##########
@@ -83,15 +83,60 @@ def parse_patch(patch)
when /\A@@/
in_hunk = true
diffs.last[:hunks] << []
- when /\A[-+]/
+ when /\A-/
next unless in_hunk
diffs.last[:hunks].last << line.chomp
+ when /\A\+/
+ next unless in_hunk
+ diffs.last[:hunks].last <<
normalize_added_line(line.chomp)
end
end
diffs.sort_by do |diff|
diff[:path]
end
end
+
+ def generate_hunks(lines)
+ git_diff_context = 3 # The default of Git's diff.context
+ max_lines_for_same_hunk = git_diff_context * 2 + 1
+ previous_i = nil
+ grouped_change_blocks = []
+ lines.each_with_index do |line, i|
+ deleted, added = yield(line)
+ next if deleted.nil? and added.nil?
+ if previous_i.nil? or (i - previous_i) > max_lines_for_same_hunk
+ grouped_change_blocks << []
+ end
+ if i - 1 != previous_i
+ grouped_change_blocks.last << []
+ end
+ grouped_change_blocks.last.last << [deleted, added]
+ previous_i = i
+ end
+ grouped_change_blocks.collect do |change_blocks|
+ hunk = []
+ change_blocks.each do |continuous_changes|
+ continuous_changes.each do |deleted, _|
+ hunk << "-#{deleted}" if deleted
+ end
+ continuous_changes.each do |_, added|
+ hunk << "+#{added}" if added
+ end
+ end
+ hunk
+ end
+ end
+
+ def normalize_pom_xml_output_timestamp(line)
+ line.gsub(/<project\.build\.outputTimestamp>.+?</) do
+ "<project.build.outputTimestamp>2023-12-13T00:00:00Z<"
Review Comment:
Why did you change the normalized timestamp to `2023-12-13` from
`1970-01-01`?
I think that special date (`1970-01-01` is a special date because UNIX time
uses it as epoch) is better for easy to understand that we normalize our
timestamps.
##########
dev/release/test-helper.rb:
##########
@@ -83,15 +83,60 @@ def parse_patch(patch)
when /\A@@/
in_hunk = true
diffs.last[:hunks] << []
- when /\A[-+]/
+ when /\A-/
next unless in_hunk
diffs.last[:hunks].last << line.chomp
+ when /\A\+/
+ next unless in_hunk
+ diffs.last[:hunks].last <<
normalize_added_line(line.chomp)
Review Comment:
```suggestion
when /\A\+/
next unless in_hunk
diffs.last[:hunks].last << normalize_added_line(line.chomp)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]