Skip to content

Commit 19e6e04

Browse files
committed
WIP
1 parent bb32d51 commit 19e6e04

33 files changed

+6617
-68
lines changed

Cargo.lock

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ crates_io_env_vars = { path = "crates/crates_io_env_vars" }
7070
crates_io_github = { path = "crates/crates_io_github" }
7171
crates_io_index = { path = "crates/crates_io_index" }
7272
crates_io_markdown = { path = "crates/crates_io_markdown" }
73+
crates_io_trusted_publishing = { path = "crates/crates_io_trusted_publishing" }
7374
crates_io_pagerduty = { path = "crates/crates_io_pagerduty" }
7475
crates_io_session = { path = "crates/crates_io_session" }
7576
crates_io_tarball = { path = "crates/crates_io_tarball" }
@@ -139,13 +140,15 @@ utoipa-axum = "=0.2.0"
139140
bytes = "=1.10.1"
140141
crates_io_github = { path = "crates/crates_io_github", features = ["mock"] }
141142
crates_io_index = { path = "crates/crates_io_index", features = ["testing"] }
143+
crates_io_trusted_publishing = { path = "crates/crates_io_trusted_publishing", features = ["mock"] }
142144
crates_io_tarball = { path = "crates/crates_io_tarball", features = ["builder"] }
143145
crates_io_team_repo = { path = "crates/crates_io_team_repo", features = ["mock"] }
144146
crates_io_test_db = { path = "crates/crates_io_test_db" }
145147
claims = "=0.8.0"
146148
diesel = { version = "=2.2.10", features = ["r2d2"] }
147149
googletest = "=0.14.0"
148150
insta = { version = "=1.43.0", features = ["glob", "json", "redactions"] }
151+
jsonwebtoken = "=9.3.1"
149152
regex = "=1.11.1"
150153
sentry = { version = "=0.37.0", features = ["test"] }
151154
tokio = "=1.44.2"

crates/crates_io_database/src/models/version.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct NewVersion<'a> {
9191
license: Option<&'a str>,
9292
#[builder(default, name = "size")]
9393
crate_size: i32,
94-
published_by: i32,
94+
published_by: Option<i32>,
9595
checksum: &'a str,
9696
links: Option<&'a str>,
9797
rust_version: Option<&'a str>,
@@ -110,7 +110,7 @@ impl NewVersion<'_> {
110110
pub async fn save(
111111
&self,
112112
conn: &mut AsyncPgConnection,
113-
published_by_email: &str,
113+
published_by_email: Option<&str>,
114114
) -> QueryResult<Version> {
115115
use diesel::insert_into;
116116

@@ -122,13 +122,15 @@ impl NewVersion<'_> {
122122
.get_result(conn)
123123
.await?;
124124

125-
insert_into(versions_published_by::table)
126-
.values((
127-
versions_published_by::version_id.eq(version.id),
128-
versions_published_by::email.eq(published_by_email),
129-
))
130-
.execute(conn)
131-
.await?;
125+
if let Some(published_by_email) = published_by_email {
126+
insert_into(versions_published_by::table)
127+
.values((
128+
versions_published_by::version_id.eq(version.id),
129+
versions_published_by::email.eq(published_by_email),
130+
))
131+
.execute(conn)
132+
.await?;
133+
}
132134

133135
Ok(version)
134136
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "crates_io_trusted_publishing"
3+
version = "0.0.0"
4+
license = "MIT OR Apache-2.0"
5+
edition = "2024"
6+
7+
[lints]
8+
workspace = true
9+
10+
[features]
11+
mock = ["dep:mockall", "dep:serde_json"]
12+
13+
[dependencies]
14+
anyhow = "=1.0.98"
15+
async-trait = "=0.1.88"
16+
chrono = { version = "=0.4.40", features = ["serde"] }
17+
jsonwebtoken = "=9.3.1"
18+
mockall = { version = "=0.13.1", optional = true }
19+
reqwest = { version = "=0.12.15", features = ["gzip", "json"] }
20+
regex = "=1.11.1"
21+
serde = { version = "=1.0.219", features = ["derive"] }
22+
serde_json = { version = "=1.0.140", optional = true }
23+
tokio = { version = "=1.44.2", features = ["sync"] }
24+
25+
[dev-dependencies]
26+
insta = { version = "=1.43.0", features = ["json", "redactions"] }
27+
mockito = "=1.7.0"
28+
tokio = { version = "=1.44.2", features = ["macros", "rt-multi-thread"] }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# crates_io_trusted_publishing

0 commit comments

Comments
 (0)