豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit b91e464

Browse files
committed
Match release stability for dated Rust toolchain releases
1 parent b300d4d commit b91e464

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

rust_toolchain/lib/dependabot/rust_toolchain/update_checker/latest_version_finder.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def cooldown_enabled? = true
4848

4949
private
5050

51+
# rubocop:disable Metrics/PerceivedComplexity
5152
sig do
5253
params(releases: T::Array[Dependabot::Package::PackageRelease])
5354
.returns(T::Array[Dependabot::Package::PackageRelease])
@@ -75,6 +76,13 @@ def filter_by_version_type(releases)
7576
# Check that the release version is in the same channel type
7677
next unless release_channel.channel_type == current_type
7778

79+
# For DatedStability channels, also check that the stability levels match
80+
# e.g., "nightly-2025-08-19" should only match other "nightly-*" releases,
81+
# not "stable-*" or "beta-*" releases
82+
if current_type == ChannelType::DatedStability && release_channel.stability != current_channel.stability
83+
next
84+
end
85+
7886
next release unless release_channel.channel_type == ChannelType::Version
7987

8088
# For version channels, we need to ensure that the version format matches
@@ -91,6 +99,7 @@ def filter_by_version_type(releases)
9199
release.version.to_s
92100
end
93101
end
102+
# rubocop:enable Metrics/PerceivedComplexity
94103

95104
# Check if a version string is in major.minor format (e.g., "1.72" vs "1.72.0")
96105
sig { params(version_string: String).returns(T::Boolean) }

rust_toolchain/spec/dependabot/rust_toolchain/update_checker/latest_version_finder_spec.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,58 @@
179179
.to match_array(%w(nightly-2023-12-25))
180180
end
181181
end
182+
183+
context "when dependency requirement is a nightly dated channel with mixed stability releases" do
184+
let(:dependency_requirement) { "nightly-2025-08-19" }
185+
let(:dependency_version) { "nightly-2025-08-19" }
186+
let(:mock_versions) do
187+
[
188+
Dependabot::RustToolchain::Version.new("nightly-2025-08-01"),
189+
Dependabot::RustToolchain::Version.new("nightly-2025-08-19"),
190+
Dependabot::RustToolchain::Version.new("nightly-2025-08-20"),
191+
Dependabot::RustToolchain::Version.new("stable-2025-08-07"),
192+
Dependabot::RustToolchain::Version.new("stable-2025-08-14"),
193+
Dependabot::RustToolchain::Version.new("beta-2025-08-10"),
194+
Dependabot::RustToolchain::Version.new("1.72.0")
195+
]
196+
end
197+
198+
it "only includes nightly releases, not stable or beta releases" do
199+
package_details = version_finder.package_details
200+
filtered_releases = version_finder.send(:apply_post_fetch_latest_versions_filter, package_details.releases)
201+
202+
expect(filtered_releases.map { |x| x.version.to_s })
203+
.to match_array(%w(nightly-2025-08-01 nightly-2025-08-19 nightly-2025-08-20))
204+
expect(filtered_releases.map { |x| x.version.to_s })
205+
.not_to include("stable-2025-08-07", "stable-2025-08-14", "beta-2025-08-10", "1.72.0")
206+
end
207+
end
208+
209+
context "when dependency requirement is a stable dated channel with mixed stability releases" do
210+
let(:dependency_requirement) { "stable-2025-08-07" }
211+
let(:dependency_version) { "stable-2025-08-07" }
212+
let(:mock_versions) do
213+
[
214+
Dependabot::RustToolchain::Version.new("nightly-2025-08-01"),
215+
Dependabot::RustToolchain::Version.new("nightly-2025-08-19"),
216+
Dependabot::RustToolchain::Version.new("stable-2025-08-07"),
217+
Dependabot::RustToolchain::Version.new("stable-2025-08-14"),
218+
Dependabot::RustToolchain::Version.new("stable-2025-08-21"),
219+
Dependabot::RustToolchain::Version.new("beta-2025-08-10"),
220+
Dependabot::RustToolchain::Version.new("1.72.0")
221+
]
222+
end
223+
224+
it "only includes stable releases, not nightly or beta releases" do
225+
package_details = version_finder.package_details
226+
filtered_releases = version_finder.send(:apply_post_fetch_latest_versions_filter, package_details.releases)
227+
228+
expect(filtered_releases.map { |x| x.version.to_s })
229+
.to match_array(%w(stable-2025-08-07 stable-2025-08-14 stable-2025-08-21))
230+
expect(filtered_releases.map { |x| x.version.to_s })
231+
.not_to include("nightly-2025-08-01", "nightly-2025-08-19", "beta-2025-08-10", "1.72.0")
232+
end
233+
end
182234
end
183235

184236
describe "#apply_post_fetch_lowest_security_fix_versions_filter" do

0 commit comments

Comments
 (0)