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.
This commit is contained in:
Nobuyoshi Nakada 2022-11-20 18:46:50 +09:00
Родитель 779917fcc0
Коммит 230c7de252
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -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