Skip to content

Commit 3c8531c

Browse files
committed
publish: Save edition field from published Cargo.toml file in the database
1 parent 1f7ce98 commit 3c8531c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/controllers/krate/publish.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
181181
let documentation = package.documentation.map(|it| it.as_local().unwrap());
182182
let repository = package.repository.map(|it| it.as_local().unwrap());
183183
let rust_version = package.rust_version.map(|rv| rv.as_local().unwrap());
184+
let edition = package.edition.map(|rv| rv.as_local().unwrap());
184185

185186
// Make sure required fields are provided
186187
fn empty(s: Option<&String>) -> bool {
@@ -384,6 +385,8 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
384385
.filter_map(|bin| bin.name.as_deref())
385386
.collect::<Vec<_>>();
386387

388+
let edition = edition.map(|edition| edition.as_str());
389+
387390
// Read tarball from request
388391
let hex_cksum: String = Sha256::digest(&tarball_bytes).encode_hex();
389392

@@ -400,6 +403,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
400403
.maybe_rust_version(rust_version.as_deref())
401404
.has_lib(tarball_info.manifest.lib.is_some())
402405
.bin_names(bin_names.as_slice())
406+
.maybe_edition(edition)
403407
.build();
404408

405409
let version = new_version.save(conn, &verified_email_address).map_err(|error| {

src/models/version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub struct NewVersion<'a> {
9797
rust_version: Option<&'a str>,
9898
pub has_lib: Option<bool>,
9999
pub bin_names: Option<&'a [&'a str]>,
100+
edition: Option<&'a str>,
100101
}
101102

102103
impl NewVersion<'_> {

0 commit comments

Comments
 (0)