Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions bin/git-pr-release
Original file line number Diff line number Diff line change
Expand Up @@ -152,36 +152,13 @@ end
def merge_pr_body(old_body, new_body)
# Try to take over checklist statuses
pr_body_lines = []
old_body_lines = old_body.split(/\r?\n/)
new_body_lines = new_body.split(/\r?\n/)

Diff::LCS.traverse_balanced(old_body.split(/\r?\n/), new_body.split(/\r?\n/)) do |event|
say "diff: #{event.inspect}", :trace
action, old, new = *event
old_nr, old_line = *old
new_nr, new_line = *new

case action
when '=', '+'
say "Use line as is: #{new_line}", :trace
pr_body_lines << new_line
when '-'
say "Use old line: #{old_line}", :trace
pr_body_lines << old_line
when '!'
if [ old_line, new_line ].all? { |line| /^- \[[ x]\]/ === line }
say "Found checklist diff; use old one: #{old_line}", :trace
pr_body_lines << old_line
else
# not a checklist diff, use both line
say "Use line as is: #{old_line}", :trace
pr_body_lines << old_line
additional_body_lines = new_body_lines - old_body_lines

say "Use line as is: #{new_line}", :trace
pr_body_lines << new_line
end
else
say "Unknown diff event: #{event}", :warn
end
end
sepalator = ['', '## Additional PRs', '']
pr_body_lines = old_body_lines + sepalator + additional_body_lines

pr_body_lines.join("\n")
end
Expand Down