[rubygems/rubygems] Don't delete the release version from pre-release string more than once

https://github.com/rubygems/rubygems/commit/6485adda54
This commit is contained in:
Martin Emde 2023-10-10 16:41:06 -07:00 коммит произвёл git
Родитель cc311e1c45
Коммит b9a6fca67d
2 изменённых файлов: 9 добавлений и 1 удалений

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

@ -86,7 +86,7 @@ module Bundler
segments = version.segments
seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
prerelease_suffix = version.to_s.delete_prefix(version.release.to_s) if version.prerelease?
"#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
end

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

@ -9,6 +9,7 @@ RSpec.describe "bundle add" do
build_gem "bar", "0.12.3"
build_gem "cat", "0.12.3.pre"
build_gem "dog", "1.1.3.pre"
build_gem "lemur", "3.1.1.pre.2023.1.1"
end
build_git "foo", "2.0"
@ -51,6 +52,13 @@ RSpec.describe "bundle add" do
expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/)
expect(the_bundle).to include_gems "dog 1.1.3.pre"
end
it "version requirement becomes ~> major.minor.pre.tail when resolved version has a very long tail pre version" do
bundle "add 'lemur'"
# the trailing pre purposely matches the release version to ensure that subbing the release doesn't change the pre.version"
expect(bundled_app_gemfile.read).to match(/gem "lemur", "~> 3.1.pre.2023.1.1"/)
expect(the_bundle).to include_gems "lemur 3.1.1.pre.2023.1.1"
end
end
describe "with --version" do