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

ruby-changes:57488

From: Nobuyoshi <ko1@a...>
Date: Mon, 2 Sep 2019 23:31:04 +0900 (JST)
Subject: [ruby-changes:57488] 6a9c5ef186 (master): Extract git commit log as raw format like git-svn for ChangeLog

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

From 6a9c5ef186db70dc60fcd42ec820767d9a75543a Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 2 Sep 2019 23:10:58 +0900
Subject: Extract git commit log as raw format like git-svn for ChangeLog


diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index 9813181..4acc721 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -608,20 +608,19 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L608
       unless $?.success?
         raise "need notes/commits tree; run `git fetch origin refs/notes/commits:refs/notes/commits` in the repository"
       end
-      cmd = %W"#{COMMAND} log --format=medium --notes=commits --date=iso-local --topo-order"
       to ||= 'HEAD'
       if from
-        cmd.push("#{from}^..#{to}")
+        arg = ["#{from}^..#{to}"]
       else
-        cmd.push("--since=25 Dec 00:00:00", to)
-      end
-      cmd_pipe({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'}, cmd, "rb") do |r|
-        format_changelog(r, path)
+        arg = ["--since=25 Dec 00:00:00", to]
       end
+      format_changelog(path, arg)
     end
 
-    def format_changelog(r, path)
-      IO.copy_stream(r, path)
+    def format_changelog(path, arg)
+      cmd = %W"#{COMMAND} log --format=medium --notes=commits --date=iso-local --topo-order"
+      cmd.concat(arg)
+      system({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'}, *cmd, chdir: @srcdir, out: path)
     end
 
     def upstream
@@ -660,26 +659,25 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/lib/vcs.rb#L659
       SVN.revision_name(rev)
     end
 
-    def format_changelog(r, path)
+    def format_changelog(path, arg)
+      cmd = %W"#{COMMAND} log --topo-order --no-notes"
+      cmd << "--format=%x00%an%n%at%n%B"
+      cmd.concat(arg)
       open(path, 'w') do |w|
         sep = "-"*72
         w.puts sep
-        while s = r.gets('')
-          author = s[/^Author:\s*(\S+)/, 1]
-          time = s[/^Date:\s*(.+)/, 1]
-          s = r.gets('')
-          s.gsub!(/^ {4}/, '')
-          s.sub!(/^git-svn-id: .*@(\d+) .*\n+\z/, '')
-          rev = $1
-          s.gsub!(/^ {8}/, '') if /^(?! {8}|$)/ !~ s
-          s.sub!(/\n\n\z/, "\n")
-          if /\A(\d+)-(\d+)-(\d+)/ =~ time
-            date = Time.new($1.to_i, $2.to_i, $3.to_i).strftime("%a, %d %b %Y")
+        cmd_pipe(cmd) do |r|
+          r.getc                # skip first NUL
+          while s = r.gets("\0")
+            s.chomp!("\0")
+            author, time, s = s.split("\n", 3)
+            s.sub!(/\n\ngit-svn-id: .*@(\d+) .*\n\Z/, '')
+            rev = $1
+            time = Time.at(time.to_i).getlocal("+09:00").strftime("%F %T %z (%a, %d %b %Y)")
+            lines = s.count("\n")
+            lines = "#{lines} line#{lines == 1 ? '' : 's'}"
+            w.puts "r#{rev} | #{author} | #{time} | #{lines}\n\n", s, sep
           end
-          lines = s.count("\n")
-          lines = "#{lines} line#{lines == 1 ? '' : 's'}"
-          w.puts "r#{rev} | #{author} | #{time} (#{date}) | #{lines}\n\n"
-          w.puts s, sep
         end
       end
     end
-- 
cgit v0.10.2


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

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