From 7d47f3c94f4c38f9b236716c9f98b928895d6b2d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 2 Sep 2024 02:05:21 -0700 Subject: [PATCH] redmine-backporter: Clarify the actual control flow The `rev && has_commit(rev, "ruby_#{TARGET_VERSION.tr('.','_')}")` case seems to be used if and only if it's manually specified in the argument to the done command. It was hard to notice it with the previous code. --- tool/redmine-backporter.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tool/redmine-backporter.rb b/tool/redmine-backporter.rb index 73d375b146..475054641b 100755 --- a/tool/redmine-backporter.rb +++ b/tool/redmine-backporter.rb @@ -351,10 +351,9 @@ eom next end - if rev.nil? && log = find_git_log("##@issue]") - /^commit (?\h{40})$/ =~ log - end - if log && rev + if rev && has_commit(rev, "ruby_#{TARGET_VERSION.tr('.','_')}") + notes = "ruby_#{TARGET_VERSION.tr('.','_')} commit:#{rev}." + elsif rev.nil? && (log = find_git_log("##@issue]")) && /^commit (?\h{40})$/ =~ log str = log[/merge revision\(s\) ([^:]+)(?=:)/] if str str.sub!(/\Amerge/, 'merged') @@ -368,10 +367,6 @@ eom str << notes end notes = str - elsif rev && has_commit(rev, "ruby_#{TARGET_VERSION.tr('.','_')}") - # Backport commit's log doesn't have the issue number. - # Instead of that manually it's provided. - notes = "ruby_#{TARGET_VERSION.tr('.','_')} commit:#{rev}." else puts "no commit is found whose log include ##@issue" next