summaryrefslogtreecommitdiff
path: root/tool/lib/vcs.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-08 23:55:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-08 23:56:01 +0900
commita0faad38ce6b2a32f33cd045d1c26f4f55d3afe5 (patch)
treee12a967bc7d16d8cf9bb83e4d9bbae9ad6abc73d /tool/lib/vcs.rb
parentced09d521c4246e4a973da771ed9b2b60a8fcad3 (diff)
downloadruby-a0faad38ce6b2a32f33cd045d1c26f4f55d3afe5.tar.gz
vcs.rb: added `base_url` keyword option to GIT#export_changelog
Diffstat (limited to 'tool/lib/vcs.rb')
-rw-r--r--tool/lib/vcs.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index 1b1b3c5e88..00b6cb8591 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -525,7 +525,7 @@ class VCS
#{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
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@github.com: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
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
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)