diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-23 08:42:53 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-23 09:29:05 +0900 |
commit | 80d5d220b948517306e23b18260768ab8fe008bc (patch) | |
tree | 465b82f06c439dd9db27af172f281bd58084bdb2 /tool/lib | |
parent | 4de2297d74fbc0a0e69ac8bcc2aad5b192fd11b6 (diff) | |
download | ruby-80d5d220b948517306e23b18260768ab8fe008bc.tar.gz |
Fix typo in commit logs by log-fix notes
Diffstat (limited to 'tool/lib')
-rw-r--r-- | tool/lib/vcs.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb index 1868553e74..3553ed51a9 100644 --- a/tool/lib/vcs.rb +++ b/tool/lib/vcs.rb @@ -613,6 +613,8 @@ class VCS chdir: @srcdir, exception: false) abort "Could not fetch notes/commits tree" end + system(*%W"#{COMMAND} fetch origin refs/notes/log-fix:refs/notes/log-fix", + chdir: @srcdir, exception: false) to ||= url.to_str if from arg = ["#{from}^..#{to}"] @@ -628,14 +630,32 @@ class VCS def format_changelog(path, arg) env = {'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'} - cmd = %W"#{COMMAND} log --format=medium --notes=commits --topo-order --no-merges" + cmd = %W"#{COMMAND} log --format=medium --notes=commits --notes=log-fix --topo-order --no-merges" date = "--date=iso-local" unless system(env, *cmd, date, chdir: @srcdir, out: NullDevice, exception: false) date = "--date=iso" end cmd << date cmd.concat(arg) - system(env, *cmd, chdir: @srcdir, out: path) + File.open(path, 'w') do |w| + cmd_pipe(env, cmd, chdir: @srcdir) do |r| + while s = r.gets("\ncommit ") + if s.sub!(/\nNotes \(log-fix\):\n((?: +.*\n)+)/, '') + fix = $1 + h, s = s.split(/^$/, 2) + s = s.lines + fix.each_line do |x| + if %r[^ +(\d+)s/(.+)/(.+)/] =~ x + s[$1.to_i][$2] = $3 + end + end + s = [h, s.join('')].join('') + end + s.gsub!(/ +\n/, "\n") + w.print s + end + end + end end def format_changelog_as_svn(path, arg) |