From 2f441c59d6df19b587e4f6bd68ab135ea8236d19 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 16 Jan 2026 06:49:09 +0900 Subject: [PATCH] Expand GitHub style references in ChangeLog to URL (#1547) Currently, ruby/ruby formats ChangeLog and expands such references to links. But such links in ChangeLog that is a plain text does not make sense. I think it is suitable to be done at conversion from ChangeLog to HTML --------- Co-authored-by: Sutou Kouhei --- lib/rdoc/parser/changelog.rb | 21 +++++++++++++++++++++ test/rdoc/parser/changelog_test.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index 85ec46e0aa..802ac96f01 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -274,6 +274,27 @@ def create_entries(entries) def initialize(base, commit, author, email, date, contents) case contents when String + if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) + repo, host = $&, $1 + contents = contents.dup + # base: https://github.com/ruby/ruby/ + # Fix #15791 -> Fix [#15791](https://github.com/ruby/ruby/pull/15791) + # GH-15791 -> [GH-15791](https://github.com/ruby/ruby/pull/15791) + # (#15791) -> ([#15791](https://github.com/ruby/ruby/pull/15791)) + contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do + "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" + end + # repo#PR, repo@HASH + # ruby/ruby#15791 -> [ruby/ruby#15791](https://github.com/ruby/ruby/pull/15791) + # ruby/ruby@a8a989b6 -> [ruby/ruby@a8a989b6](https://github.com/ruby/ruby/commit/a8a989b6) + # ref in branckets is not extended + # [ruby/net-imap#543][ruby/ruby#15791] -> [ruby/net-imap#543][ruby/ruby#15791] + contents.gsub!(%r[(?