[前][次][番号順一覧][スレッド一覧]

ruby-changes:65189

From: Nobuyoshi <ko1@a...>
Date: Tue, 9 Feb 2021 00:07:28 +0900 (JST)
Subject: [ruby-changes:65189] a0faad38ce (master): vcs.rb: added `base_url` keyword option to GIT#export_changelog

https://git.ruby-lang.org/ruby.git/commit/?id=a0faad38ce

From a0faad38ce6b2a32f33cd045d1c26f4f55d3afe5 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 8 Feb 2021 23:55:08 +0900
Subject: vcs.rb: added `base_url` keyword option to GIT#export_changelog

---
 tool/lib/vcs.rb | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index 1b1b3c5..00b6cb8 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -525,7 +525,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L525
                    #{url.to_str} -- version.h include/ruby/version.h])
     end
 
-    def export_changelog(url = '@', from = nil, to = nil, _path = nil, path: _path)
+    def export_changelog(url = '@', from = nil, to = nil, _path = nil, path: _path, base_url: nil)
       svn = nil
       from, to = [from, to].map do |rev|
         rev or next
@@ -558,7 +558,17 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L558
         if svn
           format_changelog_as_svn(path, arg)
         else
-          format_changelog(path, arg)
+          if base_url == true
+            remote, = upstream
+            if remote &&= cmd_read(env, %W[#{COMMAND} remote get-url --no-push #{remote}])
+              remote.chomp!
+              # hack to redirect git.r-l.o to github
+              remote.sub!(/\Agit@git\.ruby-lang\.org:/, 'git@g...:ruby/')
+              remote.sub!(/\Agit@(.*?):(.*?)(?:\.git)?\z/, 'https://\1/\2/commit/')
+            end
+            base_url = remote
+          end
+          format_changelog(path, arg, base_url)
         end
       if !path or path == '-'
         writer[$stdout]
@@ -567,7 +577,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L577
       end
     end
 
-    def format_changelog(path, arg)
+    def format_changelog(path, arg, base_url = nil)
       env = {'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'}
       cmd = %W"#{COMMAND} log --format=fuller --notes=commits --notes=log-fix --topo-order --no-merges"
       date = "--date=iso-local"
@@ -578,6 +588,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L588
       cmd.concat(arg)
       proc do |w|
         w.print "-*- coding: utf-8 -*-\n\n"
+        w.print "base-url = #{base_url}\n\n" if base_url
         cmd_pipe(env, cmd, chdir: @srcdir) do |r|
           while s = r.gets("\ncommit ")
             h, s = s.split(/^$/, 2)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]