From b6fd7b1bb741edfe08b9f9da4652b5e1d5d3a57a Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sun, 21 Apr 2019 14:24:38 +0000 Subject: tool/redmine-backporter.rb: Git support in backport/rel close https://github.com/ruby/ruby/pull/2138 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/redmine-backporter.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'tool') diff --git a/tool/redmine-backporter.rb b/tool/redmine-backporter.rb index 241b285d41..eef8bbb3ca 100755 --- a/tool/redmine-backporter.rb +++ b/tool/redmine-backporter.rb @@ -262,9 +262,11 @@ end def backport_command_string unless @changesets.respond_to?(:validated) @changesets = @changesets.select do |c| - # check if the revision is included in trunk + next false if c.match(/\A\d{1,6}\z/) # skip SVN revision + + # check if the Git revision is included in trunk begin - uri = URI("#{REDMINE_BASE}/projects/ruby-trunk/repository/trunk/revisions/#{c}") + uri = URI("#{REDMINE_BASE}/projects/ruby-trunk/repository/ruby-git/revisions/#{c}") uri.read($openuri_options) true rescue @@ -369,13 +371,21 @@ eom "rel" => proc{|args| # this feature requires custom redmine which allows add_related_issue API - raise CommandSyntaxError unless /\Ar?(\d+)\z/ =~ args + case args + when /\Ar?(\d+)\z/ # SVN + rev = $1 + uri = URI("#{REDMINE_BASE}/projects/ruby-trunk/repository/trunk/revisions/#{rev}/issues.json") + when /\A\h{7,40}\z/ # Git + rev = args + uri = URI("#{REDMINE_BASE}/projects/ruby-trunk/repository/ruby-git/revisions/#{rev}/issues.json") + else + raise CommandSyntaxError + end unless @issue puts "ticket not selected" next end - rev = $1 - uri = URI("#{REDMINE_BASE}/projects/ruby-trunk/repository/trunk/revisions/#{rev}/issues.json") + Net::HTTP.start(uri.host, uri.port, http_options) do |http| res = http.post(uri.path, "issue_id=#@issue", 'X-Redmine-API-Key' => REDMINE_API_KEY) @@ -385,7 +395,7 @@ eom if $!.respond_to?(:response) && $!.response.is_a?(Net::HTTPConflict) $stderr.puts "the revision has already related to the ticket" else - $stderr.puts "deployed redmine doesn't have https://github.com/ruby/bugs.ruby-lang.org/commit/01fbba60d68cb916ddbccc8a8710e68c5217171d\nask naruse or hsbt" + $stderr.puts "#{$!.class}: #{$!.message}\n\ndeployed redmine doesn't have https://github.com/ruby/bugs.ruby-lang.org/commit/01fbba60d68cb916ddbccc8a8710e68c5217171d\nask naruse or hsbt" end next end -- cgit v1.2.3