diff options
Diffstat (limited to 'tool/sync_default_gems.rb')
-rwxr-xr-x | tool/sync_default_gems.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index d6c7f771d7..0feb5a80b7 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -86,7 +86,8 @@ end def replace_rdoc_ref(file) src = File.binread(file) - src.gsub!(%r[\[\Khttps://docs\.ruby-lang\.org/en/master(?:/doc)?/(([A-Z]\w+(?:/[A-Z]\w+)*)|\w+_rdoc)\.html(\#\S+)?(?=\])]) do + changed = false + changed |= src.gsub!(%r[\[\Khttps://docs\.ruby-lang\.org/en/master(?:/doc)?/(([A-Z]\w+(?:/[A-Z]\w+)*)|\w+_rdoc)\.html(\#\S+)?(?=\])]) do name, mod, label = $1, $2, $3 mod &&= mod.gsub('/', '::') if label && (m = label.match(/\A\#(?:method-([ci])|(?:(?:class|module)-#{mod}-)?label)-([-+\w]+)\z/)) @@ -94,7 +95,8 @@ def replace_rdoc_ref(file) scope = scope ? scope.tr('ci', '.#') : '@' end "rdoc-ref:#{mod || name.chomp("_rdoc") + ".rdoc"}#{scope}#{label}" - end or return false + end + changed or return false File.rename(file, file + "~") File.binwrite(file, src) return true @@ -554,7 +556,11 @@ def sync_default_gems_with_commits(gem, ranges, edit: nil) next end - if replace_rdoc_ref_all + head = `git log --format=%H -1 HEAD`.chomp + system(*%w"git reset --quiet HEAD~ --") + amend = replace_rdoc_ref_all + system(*%w"git reset --quiet #{head} --") + if amend `git commit --amend --no-edit --all` end |