From 230c7de2529a0a29b5814e015d7cb66c3157513b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 20 Nov 2022 18:46:50 +0900 Subject: sync_default_gems.rb: Fix substitution [ci skip] As there should be no modified files just affter `git cherry-pick` succeeded in `sync_default_gems_with_commits`, reset to the previous revision once to pick up the committed files. --- tool/sync_default_gems.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tool/sync_default_gems.rb') 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 -- cgit v1.2.3