Skip to content

Commit

Permalink
Include rust-version in publish request
Browse files Browse the repository at this point in the history
crates.io reads rust-version from the tarball directly, but we can include it in
the publish request for the sake of consistency for third-party registries.
  • Loading branch information
cassaundra committed Apr 26, 2023
1 parent 284fd3f commit e2608b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/crates-io/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct NewCrate {
pub repository: Option<String>,
pub badges: BTreeMap<String, BTreeMap<String, String>>,
pub links: Option<String>,
pub rust_version: Option<String>,
}

#[derive(Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub struct ManifestMetadata {
pub documentation: Option<String>, // URL
pub badges: BTreeMap<String, BTreeMap<String, String>>,
pub links: Option<String>,
pub rust_version: Option<String>,
}

#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ fn transmit(
ref categories,
ref badges,
ref links,
ref rust_version,
} = *manifest.metadata();
let readme_content = readme
.as_ref()
Expand Down Expand Up @@ -398,6 +399,7 @@ fn transmit(
license_file: license_file.clone(),
badges: badges.clone(),
links: links.clone(),
rust_version: rust_version.clone(),
},
tarball,
)
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,11 @@ impl TomlManifest {
.transpose()?
.unwrap_or_default(),
links: package.links.clone(),
rust_version: package
.rust_version
.clone()
.map(|mw| mw.resolve("rust-version", || inherit()?.rust_version()))
.transpose()?,
};
package.description = metadata
.description
Expand Down

0 comments on commit e2608b8

Please sign in to comment.