summaryrefslogtreecommitdiff
path: root/tool/sync_default_gems.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-20 18:46:50 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-20 18:51:41 +0900
commit230c7de2529a0a29b5814e015d7cb66c3157513b (patch)
tree2d8d9cd57f6e8a41054e551aa0d2cfe47bf186d8 /tool/sync_default_gems.rb
parent779917fcc0db9349bc2808150030def57ac229bf (diff)
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.
Diffstat (limited to 'tool/sync_default_gems.rb')
-rwxr-xr-xtool/sync_default_gems.rb12
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