From d5d1c41728d65acfb8aa2cf95f2d8ac88f271cd1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 23 Jan 2021 00:20:53 +0900 Subject: [ruby/rdoc] Sort by CommitDate if available https://github.com/ruby/rdoc/commit/455715e930 --- lib/rdoc/parser/changelog.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/rdoc') diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index b393805040..dcc8464990 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -217,9 +217,14 @@ class RDoc::Parser::ChangeLog < RDoc::Parser def parse_entries entries = [] - @content.scan(/^commit\s+(\h{20})\h*\n *Author: *(.+)\n *Date: *(.+)\n\n((?: {4}.*\n+)*)/) do - entry_name, author, date, entry_body = $1, $2, $3, $4.gsub(/^ {4}/, '') - if /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+) *([-+]\d\d)(\d\d)/ =~ date + @content.scan(/^commit\s+(\h{20})\h*\n((?:.+\n)*)\n((?: {4}.*\n+)*)/) do + entry_name, header, entry_body = $1, $2, $3.gsub(/^ {4}/, '') + # header = header.scan(/^ *(\S+?): +(.*)/).to_h + # date = header["CommitDate"] || header["Date"] + date = header[/^ *(?:Author)?Date: +(.*)/, 1] + author = header[/^ *Author: +(.*)/, 1] + if /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+) *([-+]\d\d)(\d\d)/ =~ + (header[/^ *CommitDate: +(.*)/, 1] || date) time = Time.new($1, $2, $3, $4, $5, $6, "#{$7}:#{$8}") @time_cache[entry_name] = time author.sub!(/\s*<(.*)>/, '') -- cgit v1.2.3