From 0ca0c868bd0dddf5eaabd834258db853059d9f19 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 12 Sep 2024 16:52:01 -0400 Subject: [PATCH] Add `yank_message` field to API version responses This field can currently only be set directly in the database, but introducing it in a dedicated commit/PR makes the diff of the commit that introduces the update API much more manageable. --- .../all__krate__publish__links__crate_with_links_field-2.snap | 1 + .../all__krate__publish__manifest__boolean_readme-2.snap | 1 + .../all__krate__publish__manifest__lib_and_bin_crate-2.snap | 1 + .../crates/snapshots/all__routes__crates__read__show.snap | 3 +++ ...release_versions_not_included_in_reverse_dependencies.snap | 1 + ...s__crates__reverse_dependencies__reverse_dependencies.snap | 1 + ..._dependencies_includes_published_by_user_when_present.snap | 2 ++ ..._dependencies_query_supports_u64_version_number_parts.snap | 1 + ...endencies_when_old_version_doesnt_depend_but_new_does.snap | 1 + ..._yanked_versions_not_included_in_reverse_dependencies.snap | 1 + .../all__routes__crates__versions__list__versions.snap | 3 +++ ...__read__show_by_crate_name_and_semver_no_published_by.snap | 1 + ...rates__versions__read__show_by_crate_name_and_version.snap | 1 + src/views.rs | 4 ++++ 14 files changed, 22 insertions(+) diff --git a/src/tests/krate/publish/snapshots/all__krate__publish__links__crate_with_links_field-2.snap b/src/tests/krate/publish/snapshots/all__krate__publish__links__crate_with_links_field-2.snap index bdfaa794291..f9db5970631 100644 --- a/src/tests/krate/publish/snapshots/all__krate__publish__links__crate_with_links_field-2.snap +++ b/src/tests/krate/publish/snapshots/all__krate__publish__links__crate_with_links_field-2.snap @@ -45,6 +45,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo/1.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } } diff --git a/src/tests/krate/publish/snapshots/all__krate__publish__manifest__boolean_readme-2.snap b/src/tests/krate/publish/snapshots/all__krate__publish__manifest__boolean_readme-2.snap index 5a71c3517fb..444b4907307 100644 --- a/src/tests/krate/publish/snapshots/all__krate__publish__manifest__boolean_readme-2.snap +++ b/src/tests/krate/publish/snapshots/all__krate__publish__manifest__boolean_readme-2.snap @@ -45,6 +45,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo/1.0.0/readme", "rust_version": "1.69", "updated_at": "[datetime]", + "yank_message": null, "yanked": false } } diff --git a/src/tests/krate/publish/snapshots/all__krate__publish__manifest__lib_and_bin_crate-2.snap b/src/tests/krate/publish/snapshots/all__krate__publish__manifest__lib_and_bin_crate-2.snap index 9fd82bbd691..b02fdc80ecb 100644 --- a/src/tests/krate/publish/snapshots/all__krate__publish__manifest__lib_and_bin_crate-2.snap +++ b/src/tests/krate/publish/snapshots/all__krate__publish__manifest__lib_and_bin_crate-2.snap @@ -48,6 +48,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo/1.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } } diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__read__show.snap b/src/tests/routes/crates/snapshots/all__routes__crates__read__show.snap index 9fffd01dd43..50eeaaf38c6 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__read__show.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__read__show.snap @@ -71,6 +71,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_show/1.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false }, { @@ -103,6 +104,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_show/0.5.1/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false }, { @@ -135,6 +137,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_show/0.5.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__prerelease_versions_not_included_in_reverse_dependencies.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__prerelease_versions_not_included_in_reverse_dependencies.snap index 637d1baf5c8..f63708d807c 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__prerelease_versions_not_included_in_reverse_dependencies.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__prerelease_versions_not_included_in_reverse_dependencies.snap @@ -51,6 +51,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c3/1.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies.snap index 4e414bfd075..db8569edce1 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies.snap @@ -51,6 +51,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c2/1.1.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_includes_published_by_user_when_present.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_includes_published_by_user_when_present.snap index fc1fd08b474..167a83490c6 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_includes_published_by_user_when_present.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_includes_published_by_user_when_present.snap @@ -63,6 +63,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c3/3.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false }, { @@ -89,6 +90,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c2/2.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_query_supports_u64_version_number_parts.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_query_supports_u64_version_number_parts.snap index ea0bd10d49f..612440d5b00 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_query_supports_u64_version_number_parts.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_query_supports_u64_version_number_parts.snap @@ -51,6 +51,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c2/1.0.18446744073709551615/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_when_old_version_doesnt_depend_but_new_does.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_when_old_version_doesnt_depend_but_new_does.snap index 23bf854c3fe..9d4d30c8df8 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_when_old_version_doesnt_depend_but_new_does.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__reverse_dependencies_when_old_version_doesnt_depend_but_new_does.snap @@ -51,6 +51,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c2/2.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__yanked_versions_not_included_in_reverse_dependencies.snap b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__yanked_versions_not_included_in_reverse_dependencies.snap index 23bf854c3fe..9d4d30c8df8 100644 --- a/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__yanked_versions_not_included_in_reverse_dependencies.snap +++ b/src/tests/routes/crates/snapshots/all__routes__crates__reverse_dependencies__yanked_versions_not_included_in_reverse_dependencies.snap @@ -51,6 +51,7 @@ expression: response.json() "readme_path": "/api/v1/crates/c2/2.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__list__versions.snap b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__list__versions.snap index f2785a2b615..c66a0cdabf0 100644 --- a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__list__versions.snap +++ b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__list__versions.snap @@ -28,6 +28,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_versions/1.0.0/readme", "rust_version": "1.64", "updated_at": "[datetime]", + "yank_message": null, "yanked": false }, { @@ -60,6 +61,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_versions/0.5.1/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false }, { @@ -92,6 +94,7 @@ expression: response.json() "readme_path": "/api/v1/crates/foo_versions/0.5.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } ] diff --git a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_semver_no_published_by.snap b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_semver_no_published_by.snap index 3503c962bb6..05b780ca46b 100644 --- a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_semver_no_published_by.snap +++ b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_semver_no_published_by.snap @@ -27,6 +27,7 @@ expression: json "readme_path": "/api/v1/crates/foo_vers_show_no_pb/1.0.0/readme", "rust_version": null, "updated_at": "[datetime]", + "yank_message": null, "yanked": false } } diff --git a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_version.snap b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_version.snap index 6855bac291d..fb272150b20 100644 --- a/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_version.snap +++ b/src/tests/routes/crates/versions/snapshots/all__routes__crates__versions__read__show_by_crate_name_and_version.snap @@ -33,6 +33,7 @@ expression: json "readme_path": "/api/v1/crates/foo_vers_show/2.0.0/readme", "rust_version": "1.64", "updated_at": "[datetime]", + "yank_message": null, "yanked": false } } diff --git a/src/views.rs b/src/views.rs index 121d2f79ab5..5305f973683 100644 --- a/src/views.rs +++ b/src/views.rs @@ -558,6 +558,7 @@ pub struct EncodableVersion { pub downloads: i32, pub features: serde_json::Value, pub yanked: bool, + pub yank_message: Option, pub lib_links: Option, // NOTE: Used by shields.io, altering `license` requires a PR with shields.io pub license: Option, @@ -586,6 +587,7 @@ impl EncodableVersion { downloads, features, yanked, + yank_message, links: lib_links, license, crate_size, @@ -613,6 +615,7 @@ impl EncodableVersion { downloads, features, yanked, + yank_message, lib_links, license, links, @@ -736,6 +739,7 @@ mod tests { downloads: 0, features: serde_json::from_str("{}").unwrap(), yanked: false, + yank_message: None, license: None, lib_links: None, links: EncodableVersionLinks {