Skip to content

Commit 154e004

Browse files
authored
Merge pull request #9998 from Turbo87/more-version-columns
Add description, homepage, documentation and repository fields for versions
2 parents 40bb88f + 1da5646 commit 154e004

File tree

30 files changed

+175
-12
lines changed

30 files changed

+175
-12
lines changed

crates/crates_io_database/src/schema.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,14 @@ diesel::table! {
10131013
num_no_build -> Varchar,
10141014
/// The declared Rust Edition required to compile this version of the crate.
10151015
edition -> Nullable<Text>,
1016+
/// Value of the `description` field in the `Cargo.toml` file of this version.
1017+
description -> Nullable<Text>,
1018+
/// Value of the `homepage` field in the `Cargo.toml` file of this version.
1019+
homepage -> Nullable<Text>,
1020+
/// Value of the `documentation` field in the `Cargo.toml` file of this version.
1021+
documentation -> Nullable<Text>,
1022+
/// Value of the `repository` field in the `Cargo.toml` file of this version.
1023+
repository -> Nullable<Text>,
10161024
}
10171025
}
10181026

crates/crates_io_database_dump/src/dump-db.toml

+4
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ has_lib = "public"
247247
bin_names = "public"
248248
yank_message = "private"
249249
edition = "public"
250+
description = "public"
251+
homepage = "public"
252+
documentation = "public"
253+
repository = "public"
250254

251255
[versions_published_by.columns]
252256
version_id = "private"

crates/crates_io_database_dump/src/snapshots/[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
1818
\copy "crates_keywords" ("crate_id", "keyword_id") TO 'data/crates_keywords.csv' WITH CSV HEADER
1919
\copy (SELECT "crate_id", "created_at", "created_by", "owner_id", "owner_kind" FROM "crate_owners" WHERE NOT deleted) TO 'data/crate_owners.csv' WITH CSV HEADER
2020

21-
\copy "versions" ("bin_names", "checksum", "crate_id", "crate_size", "created_at", "downloads", "edition", "features", "has_lib", "id", "license", "links", "num", "published_by", "rust_version", "updated_at", "yanked") TO 'data/versions.csv' WITH CSV HEADER
21+
\copy "versions" ("bin_names", "checksum", "crate_id", "crate_size", "created_at", "description", "documentation", "downloads", "edition", "features", "has_lib", "homepage", "id", "license", "links", "num", "published_by", "repository", "rust_version", "updated_at", "yanked") TO 'data/versions.csv' WITH CSV HEADER
2222
\copy "default_versions" ("crate_id", "version_id") TO 'data/default_versions.csv' WITH CSV HEADER
2323
\copy "dependencies" ("crate_id", "default_features", "explicit_name", "features", "id", "kind", "optional", "req", "target", "version_id") TO 'data/dependencies.csv' WITH CSV HEADER
2424
\copy "version_downloads" ("date", "downloads", "version_id") TO 'data/version_downloads.csv' WITH CSV HEADER

crates/crates_io_database_dump/src/snapshots/[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ BEGIN;
6060
\copy "crates_categories" ("category_id", "crate_id") FROM 'data/crates_categories.csv' WITH CSV HEADER
6161
\copy "crates_keywords" ("crate_id", "keyword_id") FROM 'data/crates_keywords.csv' WITH CSV HEADER
6262
\copy "crate_owners" ("crate_id", "created_at", "created_by", "owner_id", "owner_kind") FROM 'data/crate_owners.csv' WITH CSV HEADER
63-
\copy "versions" ("bin_names", "checksum", "crate_id", "crate_size", "created_at", "downloads", "edition", "features", "has_lib", "id", "license", "links", "num", "published_by", "rust_version", "updated_at", "yanked") FROM 'data/versions.csv' WITH CSV HEADER
63+
\copy "versions" ("bin_names", "checksum", "crate_id", "crate_size", "created_at", "description", "documentation", "downloads", "edition", "features", "has_lib", "homepage", "id", "license", "links", "num", "published_by", "repository", "rust_version", "updated_at", "yanked") FROM 'data/versions.csv' WITH CSV HEADER
6464
\copy "default_versions" ("crate_id", "version_id") FROM 'data/default_versions.csv' WITH CSV HEADER
6565
\copy "dependencies" ("crate_id", "default_features", "explicit_name", "features", "id", "kind", "optional", "req", "target", "version_id") FROM 'data/dependencies.csv' WITH CSV HEADER
6666
\copy "version_downloads" ("date", "downloads", "version_id") FROM 'data/version_downloads.csv' WITH CSV HEADER
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table versions
2+
drop column description,
3+
drop column homepage,
4+
drop column documentation,
5+
drop column repository;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
alter table versions
2+
add column description text,
3+
add column homepage text,
4+
add column documentation text,
5+
add column repository text;
6+
7+
comment on column versions.description is 'Value of the `description` field in the `Cargo.toml` file of this version.';
8+
comment on column versions.homepage is 'Value of the `homepage` field in the `Cargo.toml` file of this version.';
9+
comment on column versions.documentation is 'Value of the `documentation` field in the `Cargo.toml` file of this version.';
10+
comment on column versions.repository is 'Value of the `repository` field in the `Cargo.toml` file of this version.';

src/controllers/krate/publish.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
9292

9393
if let Some(deleted_crate) = deleted_crate {
9494
return Err(bad_request(format!(
95-
"A crate with the name `{}` was recently deleted. Reuse of this name will be available after {}.",
96-
deleted_crate.0,
97-
deleted_crate.1.to_rfc3339_opts(SecondsFormat::Secs, true)
98-
)));
95+
"A crate with the name `{}` was recently deleted. Reuse of this name will be available after {}.",
96+
deleted_crate.0,
97+
deleted_crate.1.to_rfc3339_opts(SecondsFormat::Secs, true)
98+
)));
9999
}
100100

101101
// this query should only be used for the endpoint scope calculation
@@ -394,6 +394,10 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
394394
.has_lib(tarball_info.manifest.lib.is_some())
395395
.bin_names(bin_names.as_slice())
396396
.maybe_edition(edition)
397+
.maybe_description(description.as_deref())
398+
.maybe_homepage(homepage.as_deref())
399+
.maybe_documentation(documentation.as_deref())
400+
.maybe_repository(repository.as_deref())
397401
.build();
398402

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

src/models/version.rs

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ pub struct Version {
3434
pub yank_message: Option<String>,
3535
pub num_no_build: String,
3636
pub edition: Option<String>,
37+
pub description: Option<String>,
38+
pub homepage: Option<String>,
39+
pub documentation: Option<String>,
40+
pub repository: Option<String>,
3741
}
3842

3943
impl Version {
@@ -95,6 +99,10 @@ pub struct NewVersion<'a> {
9599
pub has_lib: Option<bool>,
96100
pub bin_names: Option<&'a [&'a str]>,
97101
edition: Option<&'a str>,
102+
description: Option<&'a str>,
103+
homepage: Option<&'a str>,
104+
documentation: Option<&'a str>,
105+
repository: Option<&'a str>,
98106
}
99107

100108
impl NewVersion<'_> {

src/tests/krate/publish/snapshots/crates_io__tests__krate__publish__edition__edition_is_saved-2.snap

+4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ snapshot_kind: text
2323
"crate": "foo",
2424
"crate_size": 169,
2525
"created_at": "[datetime]",
26+
"description": "description",
2627
"dl_path": "/api/v1/crates/foo/1.0.0/download",
28+
"documentation": null,
2729
"downloads": 0,
2830
"edition": "2021",
2931
"features": {},
3032
"has_lib": false,
33+
"homepage": null,
3134
"id": "[id]",
3235
"lib_links": null,
3336
"license": "MIT",
@@ -45,6 +48,7 @@ snapshot_kind: text
4548
"url": "https://github.com/foo"
4649
},
4750
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
51+
"repository": null,
4852
"rust_version": "1.0",
4953
"updated_at": "[datetime]",
5054
"yank_message": null,

src/tests/krate/publish/snapshots/crates_io__tests__krate__publish__links__crate_with_links_field-2.snap

+4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ snapshot_kind: text
2323
"crate": "foo",
2424
"crate_size": 162,
2525
"created_at": "[datetime]",
26+
"description": "foo?!",
2627
"dl_path": "/api/v1/crates/foo/1.0.0/download",
28+
"documentation": null,
2729
"downloads": 0,
2830
"edition": null,
2931
"features": {},
3032
"has_lib": false,
33+
"homepage": null,
3134
"id": "[id]",
3235
"lib_links": "git2",
3336
"license": "MIT",
@@ -45,6 +48,7 @@ snapshot_kind: text
4548
"url": "https://github.com/foo"
4649
},
4750
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
51+
"repository": null,
4852
"rust_version": null,
4953
"updated_at": "[datetime]",
5054
"yank_message": null,

src/tests/krate/publish/snapshots/crates_io__tests__krate__publish__manifest__boolean_readme-2.snap

+4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ snapshot_kind: text
2323
"crate": "foo",
2424
"crate_size": 170,
2525
"created_at": "[datetime]",
26+
"description": "description",
2627
"dl_path": "/api/v1/crates/foo/1.0.0/download",
28+
"documentation": null,
2729
"downloads": 0,
2830
"edition": null,
2931
"features": {},
3032
"has_lib": false,
33+
"homepage": null,
3134
"id": "[id]",
3235
"lib_links": null,
3336
"license": "MIT",
@@ -45,6 +48,7 @@ snapshot_kind: text
4548
"url": "https://github.com/foo"
4649
},
4750
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
51+
"repository": null,
4852
"rust_version": "1.69",
4953
"updated_at": "[datetime]",
5054
"yank_message": null,

src/tests/krate/publish/snapshots/crates_io__tests__krate__publish__manifest__lib_and_bin_crate-2.snap

+4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ snapshot_kind: text
2626
"crate": "foo",
2727
"crate_size": 241,
2828
"created_at": "[datetime]",
29+
"description": "description",
2930
"dl_path": "/api/v1/crates/foo/1.0.0/download",
31+
"documentation": null,
3032
"downloads": 0,
3133
"edition": null,
3234
"features": {},
3335
"has_lib": true,
36+
"homepage": null,
3437
"id": "[id]",
3538
"lib_links": null,
3639
"license": "MIT",
@@ -48,6 +51,7 @@ snapshot_kind: text
4851
"url": "https://github.com/foo"
4952
},
5053
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
54+
"repository": null,
5155
"rust_version": null,
5256
"updated_at": "[datetime]",
5357
"yank_message": null,

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank-2.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ snapshot_kind: text
5959
"rust_version": null,
6060
"has_lib": false,
6161
"bin_names": [],
62-
"edition": null
62+
"edition": null,
63+
"description": "description",
64+
"homepage": null,
65+
"documentation": null,
66+
"repository": null
6367
}
6468
}

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank-3.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ snapshot_kind: text
7070
"rust_version": null,
7171
"has_lib": false,
7272
"bin_names": [],
73-
"edition": null
73+
"edition": null,
74+
"description": "description",
75+
"homepage": null,
76+
"documentation": null,
77+
"repository": null
7478
}
7579
}

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank-4.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ snapshot_kind: text
7070
"rust_version": null,
7171
"has_lib": false,
7272
"bin_names": [],
73-
"edition": null
73+
"edition": null,
74+
"description": "description",
75+
"homepage": null,
76+
"documentation": null,
77+
"repository": null
7478
}
7579
}

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank-5.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ snapshot_kind: text
8181
"rust_version": null,
8282
"has_lib": false,
8383
"bin_names": [],
84-
"edition": null
84+
"edition": null,
85+
"description": "description",
86+
"homepage": null,
87+
"documentation": null,
88+
"repository": null
8589
}
8690
}

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank-6.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ snapshot_kind: text
8181
"rust_version": null,
8282
"has_lib": false,
8383
"bin_names": [],
84-
"edition": null
84+
"edition": null,
85+
"description": "description",
86+
"homepage": null,
87+
"documentation": null,
88+
"repository": null
8589
}
8690
}

src/tests/krate/snapshots/crates_io__tests__krate__yanking__patch_version_yank_unyank.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ snapshot_kind: text
5959
"rust_version": null,
6060
"has_lib": false,
6161
"bin_names": [],
62-
"edition": null
62+
"edition": null,
63+
"description": "description",
64+
"homepage": null,
65+
"documentation": null,
66+
"repository": null
6367
}
6468
}

src/tests/routes/crates/snapshots/crates_io__tests__routes__crates__read__show.snap

+12
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ snapshot_kind: text
5757
"crate": "foo_show",
5858
"crate_size": 0,
5959
"created_at": "[datetime]",
60+
"description": null,
6061
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
62+
"documentation": null,
6163
"downloads": 0,
6264
"edition": null,
6365
"features": {},
6466
"has_lib": null,
67+
"homepage": null,
6568
"id": 1,
6669
"lib_links": null,
6770
"license": null,
@@ -73,6 +76,7 @@ snapshot_kind: text
7376
"num": "1.0.0",
7477
"published_by": null,
7578
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
79+
"repository": null,
7680
"rust_version": null,
7781
"updated_at": "[datetime]",
7882
"yank_message": null,
@@ -85,11 +89,14 @@ snapshot_kind: text
8589
"crate": "foo_show",
8690
"crate_size": 0,
8791
"created_at": "[datetime]",
92+
"description": null,
8893
"dl_path": "/api/v1/crates/foo_show/0.5.1/download",
94+
"documentation": null,
8995
"downloads": 0,
9096
"edition": null,
9197
"features": {},
9298
"has_lib": null,
99+
"homepage": null,
93100
"id": 3,
94101
"lib_links": null,
95102
"license": null,
@@ -107,6 +114,7 @@ snapshot_kind: text
107114
"url": "https://github.com/foo"
108115
},
109116
"readme_path": "/api/v1/crates/foo_show/0.5.1/readme",
117+
"repository": null,
110118
"rust_version": null,
111119
"updated_at": "[datetime]",
112120
"yank_message": null,
@@ -119,11 +127,14 @@ snapshot_kind: text
119127
"crate": "foo_show",
120128
"crate_size": 0,
121129
"created_at": "[datetime]",
130+
"description": null,
122131
"dl_path": "/api/v1/crates/foo_show/0.5.0/download",
132+
"documentation": null,
123133
"downloads": 0,
124134
"edition": null,
125135
"features": {},
126136
"has_lib": null,
137+
"homepage": null,
127138
"id": 2,
128139
"lib_links": null,
129140
"license": null,
@@ -141,6 +152,7 @@ snapshot_kind: text
141152
"url": "https://github.com/foo"
142153
},
143154
"readme_path": "/api/v1/crates/foo_show/0.5.0/readme",
155+
"repository": null,
144156
"rust_version": null,
145157
"updated_at": "[datetime]",
146158
"yank_message": null,

src/tests/routes/crates/snapshots/crates_io__tests__routes__crates__read__show_all_yanked.snap

+8
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ snapshot_kind: text
5656
"crate": "foo_show",
5757
"crate_size": 0,
5858
"created_at": "[datetime]",
59+
"description": null,
5960
"dl_path": "/api/v1/crates/foo_show/1.0.0/download",
61+
"documentation": null,
6062
"downloads": 0,
6163
"edition": null,
6264
"features": {},
6365
"has_lib": null,
66+
"homepage": null,
6467
"id": 1,
6568
"lib_links": null,
6669
"license": null,
@@ -78,6 +81,7 @@ snapshot_kind: text
7881
"url": "https://github.com/foo"
7982
},
8083
"readme_path": "/api/v1/crates/foo_show/1.0.0/readme",
84+
"repository": null,
8185
"rust_version": null,
8286
"updated_at": "[datetime]",
8387
"yank_message": null,
@@ -90,11 +94,14 @@ snapshot_kind: text
9094
"crate": "foo_show",
9195
"crate_size": 0,
9296
"created_at": "[datetime]",
97+
"description": null,
9398
"dl_path": "/api/v1/crates/foo_show/0.5.0/download",
99+
"documentation": null,
94100
"downloads": 0,
95101
"edition": null,
96102
"features": {},
97103
"has_lib": null,
104+
"homepage": null,
98105
"id": 2,
99106
"lib_links": null,
100107
"license": null,
@@ -112,6 +119,7 @@ snapshot_kind: text
112119
"url": "https://github.com/foo"
113120
},
114121
"readme_path": "/api/v1/crates/foo_show/0.5.0/readme",
122+
"repository": null,
115123
"rust_version": null,
116124
"updated_at": "[datetime]",
117125
"yank_message": null,

0 commit comments

Comments
 (0)