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

ruby-changes:65190

From: Nobuyoshi <ko1@a...>
Date: Tue, 9 Feb 2021 00:07:29 +0900 (JST)
Subject: [ruby-changes:65190] ced09d521c (master): vcs.rb: improved export_changelog

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

From ced09d521c4246e4a973da771ed9b2b60a8fcad3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 8 Feb 2021 23:45:51 +0900
Subject: vcs.rb: improved export_changelog

* arguments are optional
* `path` may be passed as a keyword argument
* `nil` or `"-"` path means stdout
---
 tool/lib/vcs.rb | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index c5e75b9..1b1b3c5 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -341,7 +341,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L341
       rev.to_i if rev
     end
 
-    def export_changelog(url, from, to, path)
+    def export_changelog(url = '.', from = nil, to = nil, _path = nil, path: _path)
       range = [to || 'HEAD', (from ? from+1 : branch_beginning(url))].compact.join(':')
       IO.popen({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
                %W"#{COMMAND} log -r#{range} #{url}") do |r|
@@ -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, to, path)
+    def export_changelog(url = '@', from = nil, to = nil, _path = nil, path: _path)
       svn = nil
       from, to = [from, to].map do |rev|
         rev or next
@@ -554,10 +554,16 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L554
       else
         arg = ["--since=25 Dec 00:00:00", to]
       end
-      if svn
-        format_changelog_as_svn(path, arg)
+      writer =
+        if svn
+          format_changelog_as_svn(path, arg)
+        else
+          format_changelog(path, arg)
+        end
+      if !path or path == '-'
+        writer[$stdout]
       else
-        format_changelog(path, arg)
+        File.open(path, 'wb', &writer)
       end
     end
 
@@ -570,7 +576,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L576
       end
       cmd << date
       cmd.concat(arg)
-      File.open(path, 'w') do |w|
+      proc do |w|
         w.print "-*- coding: utf-8 -*-\n\n"
         cmd_pipe(env, cmd, chdir: @srcdir) do |r|
           while s = r.gets("\ncommit ")
@@ -616,7 +622,7 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L622
     def format_changelog_as_svn(path, arg)
       cmd = %W"#{COMMAND} log --topo-order --no-notes -z --format=%an%n%at%n%B"
       cmd.concat(arg)
-      File.open(path, 'w') do |w|
+      proc do |w|
         sep = "-"*72 + "\n"
         w.print sep
         cmd_pipe(cmd) do |r|
-- 
cgit v1.1


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

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