jbonofre commented on PR #39215:
URL: https://github.com/apache/arrow/pull/39215#issuecomment-1864092947

   > How about this for "Dev /Source Release and Merge Script" failures?
   > 
   > ```diff
   > diff --git a/dev/release/01-prepare-test.rb 
b/dev/release/01-prepare-test.rb
   > index 8fb23f45f0..f4bf01f1f6 100644
   > --- a/dev/release/01-prepare-test.rb
   > +++ b/dev/release/01-prepare-test.rb
   > @@ -264,18 +264,17 @@ class PrepareTest < Test::Unit::TestCase
   >      end
   >  
   >      Dir.glob("java/**/pom.xml") do |path|
   > -      version = "<version>#{@snapshot_version}</version>"
   > -      lines = File.readlines(path, chomp: true)
   > -      target_lines = lines.grep(/#{Regexp.escape(version)}/)
   > -      hunks = []
   > -      target_lines.each do |line|
   > -        new_line = line.gsub(@snapshot_version) do
   > -          @release_version
   > +      hunks = generate_hunks(File.readlines(path, chomp: true)) do |line|
   > +        if line.include?("<version>#{@snapshot_version}</version>")
   > +          new_line = line.gsub(@snapshot_version) do
   > +            @release_version
   > +          end
   > +          [line, new_line]
   > +        elsif line.include?("<project.build.outputTimestamp>")
   > +          [line, normalize_pom_xml_output_timestamp(line)]
   > +        else
   > +          [nil, nil]
   >          end
   > -        hunks << [
   > -          "-#{line}",
   > -          "+#{new_line}",
   > -        ]
   >        end
   >        expected_changes << {hunks: hunks, path: path}
   >      end
   > diff --git a/dev/release/post-11-bump-versions-test.rb 
b/dev/release/post-11-bump-versions-test.rb
   > index 4b6933d610..08a900f71c 100644
   > --- a/dev/release/post-11-bump-versions-test.rb
   > +++ b/dev/release/post-11-bump-versions-test.rb
   > @@ -244,37 +244,19 @@ class PostBumpVersionsTest < Test::Unit::TestCase
   >        end
   >  
   >        import_path = 
"github.com/apache/arrow/go/v#{@snapshot_major_version}"
   > -      hunks = []
   >        if release_type == :major
   > -        lines = File.readlines(path, chomp: true)
   > -        target_lines = lines.each_with_index.select do |line, i|
   > -          line.include?(import_path)
   > -        end
   > -        next if target_lines.empty?
   > -        n_context_lines = 3 # The default of Git's diff.context
   > -        target_hunks = [[target_lines.first[0]]]
   > -        previous_i = target_lines.first[1]
   > -        target_lines[1..-1].each do |line, i|
   > -          if i - previous_i < n_context_lines
   > -            target_hunks.last << line
   > -          else
   > -            target_hunks << [line]
   > -          end
   > -          previous_i = i
   > -        end
   > -        target_hunks.each do |lines|
   > -          hunk = []
   > -          lines.each do |line,|
   > -            hunk << "-#{line}"
   > -          end
   > -          lines.each do |line|
   > +        hunks = generate_hunks(File.readlines(path, chomp: true)) do 
|line|
   > +          if line.include?(import_path)
   >              new_line = line.gsub("v#{@snapshot_major_version}") do
   >                "v#{@next_major_version}"
   >              end
   > -            hunk << "+#{new_line}"
   > +            [line, new_line]
   > +          else
   > +            [nil, nil]
   >            end
   > -          hunks << hunk
   >          end
   > +      else
   > +        hunks = []
   >        end
   >        if path == "go/parquet/writer_properties.go"
   >          hunks << [
   > @@ -287,18 +269,17 @@ class PostBumpVersionsTest < Test::Unit::TestCase
   >      end
   >  
   >      Dir.glob("java/**/pom.xml") do |path|
   > -      version = "<version>#{@snapshot_version}</version>"
   > -      lines = File.readlines(path, chomp: true)
   > -      target_lines = lines.grep(/#{Regexp.escape(version)}/)
   > -      hunks = []
   > -      target_lines.each do |line|
   > -        new_line = line.gsub(@snapshot_version) do
   > -          @next_snapshot_version
   > +      hunks = generate_hunks(File.readlines(path, chomp: true)) do |line|
   > +        if line.include?("<version>#{@snapshot_version}</version>")
   > +          new_line = line.gsub(@snapshot_version) do
   > +            @next_snapshot_version
   > +          end
   > +          [line, new_line]
   > +        elsif line.include?("<project.build.outputTimestamp>")
   > +          [line, normalize_pom_xml_output_timestamp(line)]
   > +        else
   > +          [nil, nil]
   >          end
   > -        hunks << [
   > -          "-#{line}",
   > -          "+#{new_line}",
   > -        ]
   >        end
   >        expected_changes << {hunks: hunks, path: path}
   >      end
   > diff --git a/dev/release/test-helper.rb b/dev/release/test-helper.rb
   > index 3b2c3aa6e5..4238a534d1 100644
   > --- a/dev/release/test-helper.rb
   > +++ b/dev/release/test-helper.rb
   > @@ -83,15 +83,59 @@ module GitRunnable
   >        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>1970-01-01T00:00:00Z<"
   > +    end
   > +  end
   > +
   > +  def normalize_added_line(line)
   > +    normalize_pom_xml_output_timestamp(line)
   > +  end
   >  end
   >  
   >  module VersionDetectable
   > ```
   
   Yeah, as said on a comment, I fixed the maven enforcer issue, I'm not on the 
merge action issue (testing locally).


-- 
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]

Reply via email to