forge
Explore
Log in

Don't you dare go Hollow

Cargo fmt after the simplification pass

Browse files at this commit

54c6cdb548d8ad1e67f048e9f133e8f29de0614eAhmet Kaan GümüşParent: 128691a
  • style
    • cargo fmt after the simplification pass
Show full message
🎨 style: cargo fmt after the simplification pass
Cargo.lockmodified+0 -3
@@ -2145,7 +2145,6 @@ dependencies = [
2145 "forge-core",2145 "forge-core",
2146 "forge-git",2146 "forge-git",
2147 "forge-web-app",2147 "forge-web-app",
2148- "forge-web-base",
2149 "forge-web-pages",2148 "forge-web-pages",
2150 "form_urlencoded",2149 "form_urlencoded",
2151 "futures-util",2150 "futures-util",
@@ -2158,7 +2157,6 @@ dependencies = [
2158 "serde",2157 "serde",
2159 "serde_json",2158 "serde_json",
2160 "sha2 0.11.1",2159 "sha2 0.11.1",
2161- "tar",
2162 "tempfile",2160 "tempfile",
2163 "time",2161 "time",
2164 "tokio",2162 "tokio",
@@ -2169,7 +2167,6 @@ dependencies = [
2169 "webauthn-authenticator-rs",2167 "webauthn-authenticator-rs",
2170 "webauthn-rs",2168 "webauthn-rs",
2171 "webauthn-rs-proto",2169 "webauthn-rs-proto",
2172- "zip",
2173 ]2170 ]
2174 2171
2175 [[package]]2172 [[package]]
crates/forge-ci/src/config.rsmodified+4 -1
@@ -1748,7 +1748,10 @@ artifacts = ["target/release/forge"]
1748 }1748 }
1749 let many = ["\"0 3 * * *\""; MAX_SCHEDULES + 1].join(", ");1749 let many = ["\"0 3 * * *\""; MAX_SCHEDULES + 1].join(", ");
1750 let text = format!("[on]\nschedule = [{many}]\n{}", job_toml(""));1750 let text = format!("[on]\nschedule = [{many}]\n{}", job_toml(""));
1751- assert!(matches!(err_of(&text), ConfigError::TooManySchedules { .. }));1751+ assert!(matches!(
1752+ err_of(&text),
1753+ ConfigError::TooManySchedules { .. }
1754+ ));
1752 }1755 }
1753 1756
1754 #[test]1757 #[test]
crates/forge-ci/src/mask.rsmodified+4 -1
@@ -128,7 +128,10 @@ mod tests {
128 let secret = "hunter2-secret";128 let secret = "hunter2-secret";
129 let encoded = STANDARD.encode(secret.as_bytes());129 let encoded = STANDARD.encode(secret.as_bytes());
130 let m = masker(&[secret]);130 let m = masker(&[secret]);
131- assert_eq!(stream_all(&m, &[format!("leak: {encoded}").as_bytes()]), "leak: ***");131+ assert_eq!(
132+ stream_all(&m, &[format!("leak: {encoded}").as_bytes()]),
133+ "leak: ***"
134+ );
132 let other = masker(&["abcdefgh"]);135 let other = masker(&["abcdefgh"]);
133 let enc = STANDARD.encode("abcdefgh");136 let enc = STANDARD.encode("abcdefgh");
134 assert_eq!(stream_all(&other, &[enc.as_bytes()]), "***");137 assert_eq!(stream_all(&other, &[enc.as_bytes()]), "***");
crates/forge-core/src/advisories.rsmodified+1 -5
@@ -260,11 +260,7 @@ fn range_affects(range: &Range, version: &semver::Version) -> bool {
260 for event in &range.events {260 for event in &range.events {
261 match event {261 match event {
262 Event::Introduced(raw) => {262 Event::Introduced(raw) => {
263- open = Some(if raw == "0" {263+ open = Some(if raw == "0" { None } else { parse_version(raw) });
264- None
265- } else {
266- parse_version(raw)
267- });
268 }264 }
269 Event::Fixed(raw) => {265 Event::Fixed(raw) => {
270 if let Some(start) = open.take()266 if let Some(start) = open.take()
crates/forge-core/src/model.rsmodified+3 -1
@@ -9,7 +9,9 @@ pub enum Visibility {
9 Private,9 Private,
10 }10 }
11 11
12-#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]12+#[derive(
13+ Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize,
14+)]
13 #[serde(rename_all = "lowercase")]15 #[serde(rename_all = "lowercase")]
14 pub enum Role {16 pub enum Role {
15 Read,17 Read,
crates/forge-core/src/protection.rsmodified+20 -5
@@ -312,27 +312,42 @@ mod tests {
312 #[test]312 #[test]
313 fn effective_without_rules_protects_only_default() {313 fn effective_without_rules_protects_only_default() {
314 let none: &[BranchRule] = &[];314 let none: &[BranchRule] = &[];
315- assert_eq!(effective(none, "main", "main"), RuleFlags::basic(false, false));315+ assert_eq!(
316- assert_eq!(effective(none, "main", "feature"), RuleFlags::basic(true, true));316+ effective(none, "main", "main"),
317+ RuleFlags::basic(false, false)
318+ );
319+ assert_eq!(
320+ effective(none, "main", "feature"),
321+ RuleFlags::basic(true, true)
322+ );
317 }323 }
318 324
319 #[test]325 #[test]
320 fn effective_literal_allows_force_push_on_main() {326 fn effective_literal_allows_force_push_on_main() {
321 let rules = [rule("main", true, false, "1")];327 let rules = [rule("main", true, false, "1")];
322- assert_eq!(effective(&rules, "main", "main"), RuleFlags::basic(true, false));328+ assert_eq!(
329+ effective(&rules, "main", "main"),
330+ RuleFlags::basic(true, false)
331+ );
323 }332 }
324 333
325 #[test]334 #[test]
326 fn effective_literal_beats_glob() {335 fn effective_literal_beats_glob() {
327 let rules = [rule("*", false, false, "1"), rule("main", true, true, "2")];336 let rules = [rule("*", false, false, "1"), rule("main", true, true, "2")];
328- assert_eq!(effective(&rules, "main", "main"), RuleFlags::basic(true, true));337+ assert_eq!(
338+ effective(&rules, "main", "main"),
339+ RuleFlags::basic(true, true)
340+ );
329 }341 }
330 342
331 #[test]343 #[test]
332 fn effective_longer_glob_wins() {344 fn effective_longer_glob_wins() {
333 // Both `*` and `rel*` match `release`; the longer `rel*` wins even though `*` is older.345 // Both `*` and `rel*` match `release`; the longer `rel*` wins even though `*` is older.
334 let rules = [rule("*", true, true, "0"), rule("rel*", false, false, "1")];346 let rules = [rule("*", true, true, "0"), rule("rel*", false, false, "1")];
335- assert_eq!(effective(&rules, "main", "release"), RuleFlags::basic(false, false));347+ assert_eq!(
348+ effective(&rules, "main", "release"),
349+ RuleFlags::basic(false, false)
350+ );
336 // `release/**` is longer than `release/*`, so it wins for nested names.351 // `release/**` is longer than `release/*`, so it wins for nested names.
337 let rules = [352 let rules = [
338 rule("release/*", true, true, "1"),353 rule("release/*", true, true, "1"),
crates/forge-core/src/store/account_tokens.rsmodified+1 -1
@@ -7,7 +7,7 @@ use std::time::Duration;
7 7
8 use super::finish;8 use super::finish;
9 use super::{9 use super::{
10- USER_COLS, Store, col_int, col_opt_text, col_text, db_err, fetch_opt, insert_err, map_user,10+ Store, USER_COLS, col_int, col_opt_text, col_text, db_err, fetch_opt, insert_err, map_user,
11 new_id,11 new_id,
12 };12 };
13 use crate::error::{Error, Result};13 use crate::error::{Error, Result};
crates/forge-core/src/store/admin_alerts.rsmodified+3 -1
@@ -257,7 +257,9 @@ impl Store {
257 let conn = self.read_conn().await;257 let conn = self.read_conn().await;
258 fetch_opt(258 fetch_opt(
259 &conn,259 &conn,
260- &format!("SELECT {NOTICE_COLS} FROM admin_notifications WHERE id = ?1 AND user_id = ?2"),260+ &format!(
261+ "SELECT {NOTICE_COLS} FROM admin_notifications WHERE id = ?1 AND user_id = ?2"
262+ ),
261 (id.to_owned(), user_id.to_owned()),263 (id.to_owned(), user_id.to_owned()),
262 map_notice,264 map_notice,
263 )265 )
crates/forge-core/src/store/ci.rsmodified+3 -3
@@ -14,9 +14,9 @@ use super::{
14 fetch_opt, finish, insert_err, missing_row, new_id, opt_int_value, opt_text, text,14 fetch_opt, finish, insert_err, missing_row, new_id, opt_int_value, opt_text, text,
15 };15 };
16 use crate::ci::{16 use crate::ci::{
17- CiArtifact, CiJob, CiRun, CiRunner, FieldKind, JobSample, JobState, JobStep,17+ CiArtifact, CiJob, CiRun, CiRunner, FieldKind, JobSample, JobState, JobStep, MemoryOffer,
18- MemoryOffer, NewJob, NewRun, QueueSkips, RestartMode, RunState, RunnerJob, RunnerReport,18+ NewJob, NewRun, QueueSkips, RestartMode, RunState, RunnerJob, RunnerReport, RunnerRestart,
19- RunnerRestart, STARVE_AFTER_SECS, StepSample, pick_by_memory, validate_runner_field,19+ STARVE_AFTER_SECS, StepSample, pick_by_memory, validate_runner_field,
20 };20 };
21 use crate::error::{Error, Result};21 use crate::error::{Error, Result};
22 use crate::secret;22 use crate::secret;
crates/forge-core/src/store/health.rsmodified+3 -1
@@ -30,7 +30,9 @@ impl Store {
30 /// Counts of repos, users, queued CI jobs and runners. Five indexed `COUNT(*)` queries.30 /// Counts of repos, users, queued CI jobs and runners. Five indexed `COUNT(*)` queries.
31 pub async fn health_counts(&self) -> Result<HealthCounts> {31 pub async fn health_counts(&self) -> Result<HealthCounts> {
32 let conn = self.read_conn().await;32 let conn = self.read_conn().await;
33- let since = stamp_ago(std::time::Duration::from_secs(RUNNER_ONLINE_SECS.unsigned_abs()));33+ let since = stamp_ago(std::time::Duration::from_secs(
34+ RUNNER_ONLINE_SECS.unsigned_abs(),
35+ ));
34 let plain = |sql: &'static str| {36 let plain = |sql: &'static str| {
35 let conn = &conn;37 let conn = &conn;
36 async move {38 async move {
crates/forge-core/src/store/issues.rsmodified+3 -1
@@ -361,7 +361,9 @@ impl Store {
361 clauses.push("i.title LIKE ? ESCAPE '\\'");361 clauses.push("i.title LIKE ? ESCAPE '\\'");
362 params.push(Value::Text(like_pattern(query)));362 params.push(Value::Text(like_pattern(query)));
363 }363 }
364- if kind == "pull" && let Some(draft) = f.draft {364+ if kind == "pull"
365+ && let Some(draft) = f.draft
366+ {
365 clauses.push(if draft {367 clauses.push(if draft {
366 "EXISTS (SELECT 1 FROM pull_requests pr WHERE pr.issue_id = i.id AND pr.draft = 1)"368 "EXISTS (SELECT 1 FROM pull_requests pr WHERE pr.issue_id = i.id AND pr.draft = 1)"
367 } else {369 } else {
crates/forge-core/src/store/labels.rsmodified+1 -1
@@ -715,9 +715,9 @@ async fn issue_repo_id(conn: &Connection, issue_id: &str) -> Result<String> {
715 #[cfg(test)]715 #[cfg(test)]
716 mod tests {716 mod tests {
717 use super::*;717 use super::*;
718- use serde_json::Value;
719 use crate::issues::{IssueEvent, StateReason};718 use crate::issues::{IssueEvent, StateReason};
720 use crate::model::{Role, Visibility};719 use crate::model::{Role, Visibility};
720+ use serde_json::Value;
721 721
722 struct Fixture {722 struct Fixture {
723 _dir: tempfile::TempDir,723 _dir: tempfile::TempDir,
crates/forge-core/src/store/mod.rsmodified+9 -3
@@ -158,8 +158,12 @@ impl Store {
158 for _ in 0..READER_COUNT {158 for _ in 0..READER_COUNT {
159 let reader = db.connect().map_err(db_err)?;159 let reader = db.connect().map_err(db_err)?;
160 apply_pragmas(&reader).await;160 apply_pragmas(&reader).await;
161- run_pragma(&reader, "PRAGMA query_only = 1").await.map_err(db_err)?;161+ run_pragma(&reader, "PRAGMA query_only = 1")
162- run_pragma(&reader, "PRAGMA cache_size = -2048").await.map_err(db_err)?;162+ .await
163+ .map_err(db_err)?;
164+ run_pragma(&reader, "PRAGMA cache_size = -2048")
165+ .await
166+ .map_err(db_err)?;
163 readers.push(Mutex::new(reader));167 readers.push(Mutex::new(reader));
164 }168 }
165 Ok(Store {169 Ok(Store {
@@ -754,7 +758,9 @@ impl Store {
754 return Ok((None, None));758 return Ok((None, None));
755 };759 };
756 let collaborator = self.collaborator_role(&repo.id, &user.id).await?;760 let collaborator = self.collaborator_role(&repo.id, &user.id).await?;
757- let org = self.org_repo_role(&repo.owner_id, &user.id, &repo.id).await?;761+ let org = self
762+ .org_repo_role(&repo.owner_id, &user.id, &repo.id)
763+ .await?;
758 Ok((collaborator, org))764 Ok((collaborator, org))
759 }765 }
760 766
crates/forge-core/src/store/notifications.rsmodified+173 -19
@@ -4,7 +4,9 @@ use turso::transaction::Transaction;
4 use turso::{Row, Value};4 use turso::{Row, Value};
5 5
6 use super::repo_listing::VIEWER_ACCESS;6 use super::repo_listing::VIEWER_ACCESS;
7-use super::{Store, USER_COLS, col_int, col_text, db_err, fetch_all, fetch_opt, finish, map_user, new_id};7+use super::{
8+ Store, USER_COLS, col_int, col_text, db_err, fetch_all, fetch_opt, finish, map_user, new_id,
9+};
8 use crate::error::{Error, Result};10 use crate::error::{Error, Result};
9 use crate::model::{Id, User};11 use crate::model::{Id, User};
10 use crate::notifications::{Notification, Reason, SubState, WatchLevel};12 use crate::notifications::{Notification, Reason, SubState, WatchLevel};
@@ -642,8 +644,26 @@ mod tests {
642 let s = &fx.store;644 let s = &fx.store;
643 645
644 let ivy = user(s, "Ivy").await;646 let ivy = user(s, "Ivy").await;
645- notify(s, &ivy, &fx.repo, &fx.issue_a, Reason::Mention, "mentioned", Some(&fx.bob)).await;647+ notify(
646- notify(s, &ivy, &fx.repo, &fx.issue_a, Reason::Comment, "comment", Some(&fx.bob)).await;648+ s,
649+ &ivy,
650+ &fx.repo,
651+ &fx.issue_a,
652+ Reason::Mention,
653+ "mentioned",
654+ Some(&fx.bob),
655+ )
656+ .await;
657+ notify(
658+ s,
659+ &ivy,
660+ &fx.repo,
661+ &fx.issue_a,
662+ Reason::Comment,
663+ "comment",
664+ Some(&fx.bob),
665+ )
666+ .await;
647 assert_eq!(667 assert_eq!(
648 reason_of(s, &ivy, &fx.issue_a).await,668 reason_of(s, &ivy, &fx.issue_a).await,
649 Reason::Mention,669 Reason::Mention,
@@ -652,16 +672,42 @@ mod tests {
652 assert_eq!(s.unread_count(&ivy).await.unwrap(), 1, "upsert: one unread");672 assert_eq!(s.unread_count(&ivy).await.unwrap(), 1, "upsert: one unread");
653 673
654 s.mark_issue_read(&ivy, &fx.issue_a).await.unwrap();674 s.mark_issue_read(&ivy, &fx.issue_a).await.unwrap();
655- assert_eq!(s.unread_count(&ivy).await.unwrap(), 0, "upsert: marked read");675+ assert_eq!(
656- notify(s, &ivy, &fx.repo, &fx.issue_a, Reason::Comment, "comment", Some(&fx.bob)).await;676+ s.unread_count(&ivy).await.unwrap(),
677+ 0,
678+ "upsert: marked read"
679+ );
680+ notify(
681+ s,
682+ &ivy,
683+ &fx.repo,
684+ &fx.issue_a,
685+ Reason::Comment,
686+ "comment",
687+ Some(&fx.bob),
688+ )
689+ .await;
657 assert_eq!(690 assert_eq!(
658 reason_of(s, &ivy, &fx.issue_a).await,691 reason_of(s, &ivy, &fx.issue_a).await,
659 Reason::Comment,692 Reason::Comment,
660 "upsert: read row replaced"693 "upsert: read row replaced"
661 );694 );
662- assert_eq!(s.unread_count(&ivy).await.unwrap(), 1, "upsert: unread again");695+ assert_eq!(
696+ s.unread_count(&ivy).await.unwrap(),
697+ 1,
698+ "upsert: unread again"
699+ );
663 700
664- notify(s, &ivy, &fx.repo, &fx.issue_a, Reason::Assign, "assigned", None).await;701+ notify(
702+ s,
703+ &ivy,
704+ &fx.repo,
705+ &fx.issue_a,
706+ Reason::Assign,
707+ "assigned",
708+ None,
709+ )
710+ .await;
665 let inbox = s.list_notifications(&ivy, false, None, 10).await.unwrap();711 let inbox = s.list_notifications(&ivy, false, None, 10).await.unwrap();
666 assert_eq!(inbox.len(), 1, "upsert: still one row");712 assert_eq!(inbox.len(), 1, "upsert: still one row");
667 assert_eq!(713 assert_eq!(
@@ -673,8 +719,26 @@ mod tests {
673 assert_eq!(inbox[0].last_actor_name, None, "upsert: no actor given");719 assert_eq!(inbox[0].last_actor_name, None, "upsert: no actor given");
674 720
675 let kim = user(s, "Kim").await;721 let kim = user(s, "Kim").await;
676- notify(s, &kim, &fx.repo, &fx.issue_a, Reason::Comment, "comment", Some(&fx.bob)).await;722+ notify(
677- notify(s, &kim, &fx.repo, &fx.issue_b, Reason::Comment, "comment", Some(&fx.bob)).await;723+ s,
724+ &kim,
725+ &fx.repo,
726+ &fx.issue_a,
727+ Reason::Comment,
728+ "comment",
729+ Some(&fx.bob),
730+ )
731+ .await;
732+ notify(
733+ s,
734+ &kim,
735+ &fx.repo,
736+ &fx.issue_b,
737+ Reason::Comment,
738+ "comment",
739+ Some(&fx.bob),
740+ )
741+ .await;
678 s.mark_issue_read(&kim, &fx.issue_b).await.unwrap();742 s.mark_issue_read(&kim, &fx.issue_b).await.unwrap();
679 743
680 let all = s.list_notifications(&kim, false, None, 50).await.unwrap();744 let all = s.list_notifications(&kim, false, None, 50).await.unwrap();
@@ -720,9 +784,36 @@ mod tests {
720 784
721 let ned = user(s, "Ned").await;785 let ned = user(s, "Ned").await;
722 let olive = user(s, "Olive").await;786 let olive = user(s, "Olive").await;
723- notify(s, &ned, &fx.repo, &fx.issue_a, Reason::Comment, "comment", None).await;787+ notify(
724- notify(s, &ned, &fx.repo, &fx.issue_b, Reason::Comment, "comment", None).await;788+ s,
725- notify(s, &olive, &fx.repo, &fx.issue_a, Reason::Comment, "comment", None).await;789+ &ned,
790+ &fx.repo,
791+ &fx.issue_a,
792+ Reason::Comment,
793+ "comment",
794+ None,
795+ )
796+ .await;
797+ notify(
798+ s,
799+ &ned,
800+ &fx.repo,
801+ &fx.issue_b,
802+ Reason::Comment,
803+ "comment",
804+ None,
805+ )
806+ .await;
807+ notify(
808+ s,
809+ &olive,
810+ &fx.repo,
811+ &fx.issue_a,
812+ Reason::Comment,
813+ "comment",
814+ None,
815+ )
816+ .await;
726 assert_eq!(s.unread_count(&ned).await.unwrap(), 2, "read: two unread");817 assert_eq!(s.unread_count(&ned).await.unwrap(), 2, "read: two unread");
727 818
728 let inbox = s.list_notifications(&ned, false, None, 50).await.unwrap();819 let inbox = s.list_notifications(&ned, false, None, 50).await.unwrap();
@@ -738,7 +829,16 @@ mod tests {
738 s.mark_read(&ned, &inbox[1].id).await.unwrap();829 s.mark_read(&ned, &inbox[1].id).await.unwrap();
739 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: second by id");830 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: second by id");
740 831
741- notify(s, &ned, &fx.repo, &fx.issue_a, Reason::Comment, "comment", None).await;832+ notify(
833+ s,
834+ &ned,
835+ &fx.repo,
836+ &fx.issue_a,
837+ Reason::Comment,
838+ "comment",
839+ None,
840+ )
841+ .await;
742 s.mark_all_read(&ned, Some(&fx.repo)).await.unwrap();842 s.mark_all_read(&ned, Some(&fx.repo)).await.unwrap();
743 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: all in repo");843 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: all in repo");
744 assert_eq!(844 assert_eq!(
@@ -747,7 +847,16 @@ mod tests {
747 "read: other user kept"847 "read: other user kept"
748 );848 );
749 849
750- notify(s, &ned, &fx.repo, &fx.issue_b, Reason::Comment, "comment", None).await;850+ notify(
851+ s,
852+ &ned,
853+ &fx.repo,
854+ &fx.issue_b,
855+ Reason::Comment,
856+ "comment",
857+ None,
858+ )
859+ .await;
751 s.mark_all_read(&ned, None).await.unwrap();860 s.mark_all_read(&ned, None).await.unwrap();
752 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: all, no repo");861 assert_eq!(s.unread_count(&ned).await.unwrap(), 0, "read: all, no repo");
753 s.mark_all_read(&olive, Some("no-such-repo")).await.unwrap();862 s.mark_all_read(&olive, Some("no-such-repo")).await.unwrap();
@@ -758,8 +867,26 @@ mod tests {
758 );867 );
759 868
760 let max = user(s, "Max").await;869 let max = user(s, "Max").await;
761- notify(s, &max, &fx.repo, &fx.issue_a, Reason::Comment, "comment", None).await;870+ notify(
762- notify(s, &max, &fx.repo, &fx.issue_b, Reason::Comment, "comment", None).await;871+ s,
872+ &max,
873+ &fx.repo,
874+ &fx.issue_a,
875+ Reason::Comment,
876+ "comment",
877+ None,
878+ )
879+ .await;
880+ notify(
881+ s,
882+ &max,
883+ &fx.repo,
884+ &fx.issue_b,
885+ Reason::Comment,
886+ "comment",
887+ None,
888+ )
889+ .await;
763 s.mark_issue_read(&max, &fx.issue_a).await.unwrap();890 s.mark_issue_read(&max, &fx.issue_a).await.unwrap();
764 assert_eq!(891 assert_eq!(
765 s.unread_count(&max).await.unwrap(),892 s.unread_count(&max).await.unwrap(),
@@ -795,7 +922,16 @@ mod tests {
795 s.subscribe(&pat, &doomed_issue, SubState::Subscribed, Reason::Author)922 s.subscribe(&pat, &doomed_issue, SubState::Subscribed, Reason::Author)
796 .await923 .await
797 .unwrap();924 .unwrap();
798- notify(s, &pat, &doomed, &doomed_issue, Reason::Comment, "comment", Some(&fx.bob)).await;925+ notify(
926+ s,
927+ &pat,
928+ &doomed,
929+ &doomed_issue,
930+ Reason::Comment,
931+ "comment",
932+ Some(&fx.bob),
933+ )
934+ .await;
799 935
800 s.delete_repo(&doomed).await.unwrap();936 s.delete_repo(&doomed).await.unwrap();
801 assert_eq!(937 assert_eq!(
@@ -843,8 +979,26 @@ mod tests {
843 s.subscribe(&quin, &fx.issue_a, SubState::Subscribed, Reason::Author)979 s.subscribe(&quin, &fx.issue_a, SubState::Subscribed, Reason::Author)
844 .await980 .await
845 .unwrap();981 .unwrap();
846- notify(s, &ray, &fx.repo, &fx.issue_a, Reason::Comment, "comment", Some(&quin)).await;982+ notify(
847- notify(s, &quin, &fx.repo, &fx.issue_b, Reason::Comment, "comment", Some(&fx.bob)).await;983+ s,
984+ &ray,
985+ &fx.repo,
986+ &fx.issue_a,
987+ Reason::Comment,
988+ "comment",
989+ Some(&quin),
990+ )
991+ .await;
992+ notify(
993+ s,
994+ &quin,
995+ &fx.repo,
996+ &fx.issue_b,
997+ Reason::Comment,
998+ "comment",
999+ Some(&fx.bob),
1000+ )
1001+ .await;
848 1002
849 s.delete_user(&quin, &ghost.id).await.unwrap();1003 s.delete_user(&quin, &ghost.id).await.unwrap();
850 1004
crates/forge-core/src/store/pulls.rsmodified+2 -3
@@ -3,9 +3,8 @@ use turso::{Connection, Row};
3 3
4 use super::issues::{insert_event, map_issue, parse_db};4 use super::issues::{insert_event, map_issue, parse_db};
5 use super::{5 use super::{
6- finish,6+ REPO_COLS, Store, col_int, col_opt_text, col_text, db_err, fetch_all, fetch_opt, finish,
7- REPO_COLS, Store, col_int, col_opt_text, col_text, db_err, fetch_all, fetch_opt, insert_err,7+ insert_err, map_repo, new_id,
8- map_repo, new_id,
9 };8 };
10 use crate::error::{Error, Result};9 use crate::error::{Error, Result};
11 use crate::issues::{IssueFilter, IssueListItem, IssueState, validate_body, validate_title};10 use crate::issues::{IssueFilter, IssueListItem, IssueState, validate_body, validate_title};
crates/forge-core/src/store/pulls_list_extra.rsmodified+4 -2
@@ -10,13 +10,15 @@ use crate::error::Result;
10 impl Store {10 impl Store {
11 /// Which of `numbers` are draft pull requests of this repo.11 /// Which of `numbers` are draft pull requests of this repo.
12 pub async fn draft_numbers(&self, repo_id: &str, numbers: &[i64]) -> Result<HashSet<i64>> {12 pub async fn draft_numbers(&self, repo_id: &str, numbers: &[i64]) -> Result<HashSet<i64>> {
13- self.pull_numbers_where(repo_id, numbers, "p.draft = 1").await13+ self.pull_numbers_where(repo_id, numbers, "p.draft = 1")
14+ .await
14 }15 }
15 16
16 /// Which of `numbers` are merged pull requests of this repo. Numbers that are issues, open17 /// Which of `numbers` are merged pull requests of this repo. Numbers that are issues, open
17 /// or closed without a merge are left out.18 /// or closed without a merge are left out.
18 pub async fn merged_numbers(&self, repo_id: &str, numbers: &[i64]) -> Result<HashSet<i64>> {19 pub async fn merged_numbers(&self, repo_id: &str, numbers: &[i64]) -> Result<HashSet<i64>> {
19- self.pull_numbers_where(repo_id, numbers, "p.merged_at IS NOT NULL").await20+ self.pull_numbers_where(repo_id, numbers, "p.merged_at IS NOT NULL")
21+ .await
20 }22 }
21 23
22 async fn pull_numbers_where(24 async fn pull_numbers_where(
crates/forge-core/src/store/reviews.rsmodified+2 -3
@@ -10,9 +10,8 @@ use turso::{Connection, Row};
10 10
11 use super::issues::{insert_event, parse_db};11 use super::issues::{insert_event, parse_db};
12 use super::{12 use super::{
13- finish,13+ Store, col_bool, col_int, col_opt_text, col_text, db_err, fetch_all, fetch_opt, finish,
14- Store, col_bool, col_int, col_opt_text, col_text, db_err, fetch_all, fetch_opt, missing_row,14+ missing_row, new_id,
15- new_id,
16 };15 };
17 use crate::error::{Error, Result};16 use crate::error::{Error, Result};
18 use crate::issues::validate_body;17 use crate::issues::validate_body;
crates/forge-e2e/tests/e2e/issue_close_e2e.rsmodified+1 -2
@@ -4,8 +4,7 @@
4 //! file, and every push is a real `git push` through the git HTTP endpoints.4 //! file, and every push is a real `git push` through the git HTTP endpoints.
5 5
6 use crate::common::{6 use crate::common::{
7- Http, input_value, launch, login, pick_ports, relaunch, run_admin, tool_on_path,7+ Http, input_value, launch, login, pick_ports, relaunch, run_admin, tool_on_path, write_config,
8- write_config,
9 };8 };
10 use std::fs;9 use std::fs;
11 use std::future::Future;10 use std::future::Future;
crates/forge-e2e/tests/e2e/lfs_e2e.rsmodified+3 -1
@@ -5,7 +5,9 @@
5 //! Git config is isolated from the developer's machine: `HOME` and `GIT_CONFIG_GLOBAL` point into5 //! Git config is isolated from the developer's machine: `HOME` and `GIT_CONFIG_GLOBAL` point into
6 //! the test's temp dir.6 //! the test's temp dir.
7 7
8-use crate::common::{Http, describe, input_value, launch, login, pick_ports, run_admin, write_config};8+use crate::common::{
9+ Http, describe, input_value, launch, login, pick_ports, run_admin, write_config,
10+};
9 use std::fs;11 use std::fs;
10 use std::path::Path;12 use std::path::Path;
11 use std::process::{Command, Output};13 use std::process::{Command, Output};
crates/forge-e2e/tests/e2e/oci_e2e.rsmodified+16 -25
@@ -365,10 +365,7 @@ async fn push_by_monolithic_and_chunked_upload_then_pull_by_tag_and_digest() {
365 );365 );
366 let res = push_blob_chunked(http, "tahinli/app", &auth, &layer_two).await;366 let res = push_blob_chunked(http, "tahinli/app", &auth, &layer_two).await;
367 assert_eq!(res.status, 201, "{}", res.text());367 assert_eq!(res.status, 201, "{}", res.text());
368- assert_eq!(368+ assert_eq!(res.header("location"), Some(blob_path(&layer_two).as_str()));
369- res.header("location"),
370- Some(blob_path(&layer_two).as_str())
371- );
372 369
373 let head = http370 let head = http
374 .send(371 .send(
@@ -381,12 +378,7 @@ async fn push_by_monolithic_and_chunked_upload_then_pull_by_tag_and_digest() {
381 .await;378 .await;
382 assert_eq!(head.status, 200);379 assert_eq!(head.status, 200);
383 assert_eq!(head.header("content-length"), Some("3000"));380 assert_eq!(head.header("content-length"), Some("3000"));
384- let blob = http381+ let blob = http.get(&blob_path(&layer_two), Some(&auth)).await;
385- .get(
386- &blob_path(&layer_two),
387- Some(&auth),
388- )
389- .await;
390 assert_eq!(blob.status, 200);382 assert_eq!(blob.status, 200);
391 assert_eq!(blob.body, layer_two);383 assert_eq!(blob.body, layer_two);
392 384
@@ -505,12 +497,7 @@ async fn bad_digests_and_missing_blobs_are_refused_with_oci_codes() {
505 assert_eq!(res.status, 400);497 assert_eq!(res.status, 400);
506 assert_eq!(res.error_code(), "NAME_INVALID");498 assert_eq!(res.error_code(), "NAME_INVALID");
507 499
508- let res = http500+ let res = http.get(&blob_path(b"absent"), Some(&auth)).await;
509- .get(
510- &blob_path(b"absent"),
511- Some(&auth),
512- )
513- .await;
514 assert_eq!(res.status, 404);501 assert_eq!(res.status, 404);
515 assert_eq!(res.error_code(), "BLOB_UNKNOWN");502 assert_eq!(res.error_code(), "BLOB_UNKNOWN");
516 }503 }
@@ -604,12 +591,7 @@ async fn a_public_image_pulls_anonymously_and_a_private_one_does_not() {
604 let anon = http.get("/v2/tahinli/app/manifests/v1", None).await;591 let anon = http.get("/v2/tahinli/app/manifests/v1", None).await;
605 assert_eq!(anon.status, 200, "{}", anon.text());592 assert_eq!(anon.status, 200, "{}", anon.text());
606 assert_eq!(anon.body, image);593 assert_eq!(anon.body, image);
607- let anon_blob = http594+ let anon_blob = http.get(&blob_path(&config), None).await;
608- .get(
609- &blob_path(&config),
610- None,
611- )
612- .await;
613 assert_eq!(anon_blob.status, 200);595 assert_eq!(anon_blob.status, 200);
614 596
615 let hidden = http.get("/v2/tahinli/secret/manifests/v1", None).await;597 let hidden = http.get("/v2/tahinli/secret/manifests/v1", None).await;
@@ -781,8 +763,14 @@ async fn deleting_tags_and_manifests_keeps_fresh_blobs_for_the_grace_period() {
781 );763 );
782 // The blobs were pushed just now: the sweep keeps a link newer than the grace period, since a764 // The blobs were pushed just now: the sweep keeps a link newer than the grace period, since a
783 // push can still be on its way to a manifest. The store test covers the sweep after it.765 // push can still be on its way to a manifest. The store test covers the sweep after it.
784- assert_eq!(http.get(&blob_path(&layer_b), Some(&auth)).await.status, 200);766+ assert_eq!(
785- assert_eq!(http.get(&blob_path(&layer_a), Some(&auth)).await.status, 200);767+ http.get(&blob_path(&layer_b), Some(&auth)).await.status,
768+ 200
769+ );
770+ assert_eq!(
771+ http.get(&blob_path(&layer_a), Some(&auth)).await.status,
772+ 200
773+ );
786 assert_eq!(http.get(&blob_path(&config), Some(&auth)).await.status, 200);774 assert_eq!(http.get(&blob_path(&config), Some(&auth)).await.status, 200);
787 775
788 let v1_digest = sha256_digest(&v1);776 let v1_digest = sha256_digest(&v1);
@@ -796,7 +784,10 @@ async fn deleting_tags_and_manifests_keeps_fresh_blobs_for_the_grace_period() {
796 )784 )
797 .await;785 .await;
798 assert_eq!(res.status, 202);786 assert_eq!(res.status, 202);
799- assert_eq!(http.get(&blob_path(&layer_a), Some(&auth)).await.status, 200);787+ assert_eq!(
788+ http.get(&blob_path(&layer_a), Some(&auth)).await.status,
789+ 200
790+ );
800 assert_eq!(http.get(&blob_path(&config), Some(&auth)).await.status, 200);791 assert_eq!(http.get(&blob_path(&config), Some(&auth)).await.status, 200);
801 let tags = http.get("/v2/tahinli/app/tags/list", Some(&auth)).await;792 let tags = http.get("/v2/tahinli/app/tags/list", Some(&auth)).await;
802 assert_eq!(tags.json()["tags"], serde_json::json!([]));793 assert_eq!(tags.json()["tags"], serde_json::json!([]));
crates/forge-e2e/tests/e2e/pulls_e2e.rsmodified+9 -63
@@ -188,13 +188,7 @@ async fn tahinli_repo_with_main(b: &Booted) -> (String, String, PathBuf) {
188 &remote(b.http_port, "tahinli", &token, "tahinli", "r"),188 &remote(b.http_port, "tahinli", &token, "tahinli", "r"),
189 &b.dir.join("tahinli-work"),189 &b.dir.join("tahinli-work"),
190 );190 );
191- commit(191+ commit(&work, "base.txt", "base\n", "base commit", TAHINLI);
192- &work,
193- "base.txt",
194- "base\n",
195- "base commit",
196- TAHINLI,
197- );
198 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/main"]);192 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/main"]);
199 (tahinli, token, work)193 (tahinli, token, work)
200 }194 }
@@ -294,13 +288,7 @@ async fn same_repo_pull_merges_and_closes_issue() {
294 assert_eq!(issue, 1);288 assert_eq!(issue, 1);
295 289
296 git(&work, &["checkout", "-q", "-b", "feature"]);290 git(&work, &["checkout", "-q", "-b", "feature"]);
297- let feature_head = commit(291+ let feature_head = commit(&work, "x.txt", "x\n", "Add x\n\nFixes #1", TAHINLI);
298- &work,
299- "x.txt",
300- "x\n",
301- "Add x\n\nFixes #1",
302- TAHINLI,
303- );
304 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature"]);292 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature"]);
305 293
306 let compare = b294 let compare = b
@@ -360,23 +348,11 @@ async fn push_to_head_branch_updates_open_pull() {
360 let (tahinli, _token, work) = tahinli_repo_with_main(&b).await;348 let (tahinli, _token, work) = tahinli_repo_with_main(&b).await;
361 349
362 git(&work, &["checkout", "-q", "-b", "feature2"]);350 git(&work, &["checkout", "-q", "-b", "feature2"]);
363- commit(351+ commit(&work, "one.txt", "1\n", "first on feature2", TAHINLI);
364- &work,
365- "one.txt",
366- "1\n",
367- "first on feature2",
368- TAHINLI,
369- );
370 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature2"]);352 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature2"]);
371 let number = open_pull(&b.http, &tahinli, "main", "feature2", "Feature two").await;353 let number = open_pull(&b.http, &tahinli, "main", "feature2", "Feature two").await;
372 354
373- let second = commit(355+ let second = commit(&work, "two.txt", "2\n", "second on feature2", TAHINLI);
374- &work,
375- "two.txt",
376- "2\n",
377- "second on feature2",
378- TAHINLI,
379- );
380 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature2"]);356 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/feature2"]);
381 357
382 let path = format!("{REPO_PATH}/pulls/{number}");358 let path = format!("{REPO_PATH}/pulls/{number}");
@@ -444,13 +420,7 @@ async fn pull_pages_follow_writes_live() {
444 let (tahinli, token, work) = tahinli_repo_with_main(&b).await;420 let (tahinli, token, work) = tahinli_repo_with_main(&b).await;
445 421
446 git(&work, &["checkout", "-q", "-b", "live"]);422 git(&work, &["checkout", "-q", "-b", "live"]);
447- let first = commit(423+ let first = commit(&work, "live.txt", "live\n", "first on live", TAHINLI);
448- &work,
449- "live.txt",
450- "live\n",
451- "first on live",
452- TAHINLI,
453- );
454 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/live"]);424 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/live"]);
455 let number = open_pull(&b.http, &tahinli, "main", "live", "Live pull").await;425 let number = open_pull(&b.http, &tahinli, "main", "live", "Live pull").await;
456 let pull = format!("{REPO_PATH}/pulls/{number}");426 let pull = format!("{REPO_PATH}/pulls/{number}");
@@ -514,13 +484,7 @@ async fn pull_pages_follow_writes_live() {
514 next_changed(&mut pull_events, "a review").await;484 next_changed(&mut pull_events, "a review").await;
515 485
516 // A push to the head branch updates the pull and the list.486 // A push to the head branch updates the pull and the list.
517- let second = commit(487+ let second = commit(&work, "second.txt", "2\n", "second on live", TAHINLI);
518- &work,
519- "second.txt",
520- "2\n",
521- "second on live",
522- TAHINLI,
523- );
524 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/live"]);488 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/live"]);
525 next_changed(&mut pull_events, "a push to the head").await;489 next_changed(&mut pull_events, "a push to the head").await;
526 next_changed(&mut list_events, "a push to the head").await;490 next_changed(&mut list_events, "a push to the head").await;
@@ -593,13 +557,7 @@ async fn fork_pull_squash_merge_credits_contributor() {
593 let bob_url = remote(b.http_port, "bob", &bob_token, "bob", "r");557 let bob_url = remote(b.http_port, "bob", &bob_token, "bob", "r");
594 let bob_work = clone(&bob_url, &b.dir.join("bob-work"));558 let bob_work = clone(&bob_url, &b.dir.join("bob-work"));
595 git(&bob_work, &["checkout", "-q", "-b", "bob-feature"]);559 git(&bob_work, &["checkout", "-q", "-b", "bob-feature"]);
596- let bob_head = commit(560+ let bob_head = commit(&bob_work, "bob.txt", "bob\n", "Bob change", BOB);
597- &bob_work,
598- "bob.txt",
599- "bob\n",
600- "Bob change",
601- BOB,
602- );
603 git(561 git(
604 &bob_work,562 &bob_work,
605 &["push", "-q", "origin", "HEAD:refs/heads/bob-feature"],563 &["push", "-q", "origin", "HEAD:refs/heads/bob-feature"],
@@ -633,24 +591,12 @@ async fn conflicting_pull_cannot_merge() {
633 591
634 // Both sides edit the same line. The pull is opened while main still matches its base.592 // Both sides edit the same line. The pull is opened while main still matches its base.
635 git(&work, &["checkout", "-q", "-b", "conflict"]);593 git(&work, &["checkout", "-q", "-b", "conflict"]);
636- commit(594+ commit(&work, "shared.txt", "branch side\n", "branch edit", TAHINLI);
637- &work,
638- "shared.txt",
639- "branch side\n",
640- "branch edit",
641- TAHINLI,
642- );
643 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/conflict"]);595 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/conflict"]);
644 let number = open_pull(&b.http, &tahinli, "main", "conflict", "Conflicting").await;596 let number = open_pull(&b.http, &tahinli, "main", "conflict", "Conflicting").await;
645 597
646 git(&work, &["checkout", "-q", "main"]);598 git(&work, &["checkout", "-q", "main"]);
647- let main_head = commit(599+ let main_head = commit(&work, "shared.txt", "main side\n", "main edit", TAHINLI);
648- &work,
649- "shared.txt",
650- "main side\n",
651- "main edit",
652- TAHINLI,
653- );
654 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/main"]);600 git(&work, &["push", "-q", "origin", "HEAD:refs/heads/main"]);
655 601
656 let path = format!("{REPO_PATH}/pulls/{number}");602 let path = format!("{REPO_PATH}/pulls/{number}");
crates/forge-e2e/tests/e2e/repo_collaborators_e2e.rsmodified+8 -2
@@ -244,7 +244,10 @@ async fn repo_collaborators_end_to_end() {
244 .await;244 .await;
245 assert_eq!(res.status, 303, "unknown user redirects with a notice");245 assert_eq!(res.status, 303, "unknown user redirects with a notice");
246 let notice_page = http246 let notice_page = http
247- .get(page, Some(&with_cookie(&olivia, &res, "forge_collab_notice")))247+ .get(
248+ page,
249+ Some(&with_cookie(&olivia, &res, "forge_collab_notice")),
250+ )
248 .await;251 .await;
249 assert!(252 assert!(
250 notice_page.body.contains("No user has that username."),253 notice_page.body.contains("No user has that username."),
@@ -258,7 +261,10 @@ async fn repo_collaborators_end_to_end() {
258 )261 )
259 .await;262 .await;
260 let notice_page = http263 let notice_page = http
261- .get(page, Some(&with_cookie(&olivia, &res, "forge_collab_notice")))264+ .get(
265+ page,
266+ Some(&with_cookie(&olivia, &res, "forge_collab_notice")),
267+ )
262 .await;268 .await;
263 assert!(269 assert!(
264 notice_page270 notice_page
crates/forge-e2e/tests/e2e/repo_settings_e2e.rsmodified+8 -2
@@ -871,7 +871,10 @@ async fn general_settings_end_to_end() {
871 .await;871 .await;
872 assert_eq!(missing.status, 303);872 assert_eq!(missing.status, 303);
873 let notice_page = http873 let notice_page = http
874- .get("/bob/gen/settings", Some(&with_cookie(&bob, &missing, "forge_settings_notice")))874+ .get(
875+ "/bob/gen/settings",
876+ Some(&with_cookie(&bob, &missing, "forge_settings_notice")),
877+ )
875 .await;878 .await;
876 assert!(879 assert!(
877 notice_page.body.contains("That branch does not exist"),880 notice_page.body.contains("That branch does not exist"),
@@ -897,7 +900,10 @@ async fn general_settings_end_to_end() {
897 .await;900 .await;
898 assert_eq!(too_long.status, 303);901 assert_eq!(too_long.status, 303);
899 let long_page = http902 let long_page = http
900- .get("/bob/gen/settings", Some(&with_cookie(&bob, &too_long, "forge_settings_notice")))903+ .get(
904+ "/bob/gen/settings",
905+ Some(&with_cookie(&bob, &too_long, "forge_settings_notice")),
906+ )
901 .await;907 .await;
902 assert!(long_page.body.contains("at most 350 characters"));908 assert!(long_page.body.contains("at most 350 characters"));
903 909
crates/forge-git/src/wiki.rsmodified+3 -1
@@ -255,7 +255,9 @@ async fn write_commit(
255 Err(Error::Failed(msg))255 Err(Error::Failed(msg))
256 if msg.contains("but expected") || msg.contains("unable to resolve reference") =>256 if msg.contains("but expected") || msg.contains("unable to resolve reference") =>
257 {257 {
258- Err(Error::RefMoved(format!("wiki {WIKI_BRANCH} moved during the edit")))258+ Err(Error::RefMoved(format!(
259+ "wiki {WIKI_BRANCH} moved during the edit"
260+ )))
259 }261 }
260 Err(e) => Err(e),262 Err(e) => Err(e),
261 }263 }
crates/forge-ssh/src/server.rsmodified+14 -16
@@ -83,22 +83,20 @@ pub async fn run<B: GitBackend>(config: SshConfig, backend: Arc<B>) -> Result<()
83 let russh_config = Arc::clone(&russh_config);83 let russh_config = Arc::clone(&russh_config);
84 tokio::spawn(async move {84 tokio::spawn(async move {
85 let _permit = permit;85 let _permit = permit;
86- let running = match tokio::time::timeout(86+ let running =
87- AUTH_TIMEOUT,87+ match tokio::time::timeout(AUTH_TIMEOUT, run_stream(russh_config, stream, client))
88- run_stream(russh_config, stream, client),88+ .await
89- )89+ {
90- .await90+ Ok(Ok(running)) => running,
91- {91+ Ok(Err(e)) => {
92- Ok(Ok(running)) => running,92+ tracing::debug!(%peer, error = %e, "ssh handshake failed");
93- Ok(Err(e)) => {93+ return;
94- tracing::debug!(%peer, error = %e, "ssh handshake failed");94+ }
95- return;95+ Err(_) => {
96- }96+ tracing::debug!(%peer, "ssh handshake timed out");
97- Err(_) => {97+ return;
98- tracing::debug!(%peer, "ssh handshake timed out");98+ }
99- return;99+ };
100- }
101- };
102 let handle = running.handle();100 let handle = running.handle();
103 tokio::spawn(async move {101 tokio::spawn(async move {
104 tokio::time::sleep(AUTH_TIMEOUT).await;102 tokio::time::sleep(AUTH_TIMEOUT).await;
crates/forge-web-account/src/pages/admin_replication.rsmodified+8 -1
@@ -313,7 +313,14 @@ async fn page_fingerprint(state: &AppState) -> Result<String> {
313 let rows: Vec<_> = data313 let rows: Vec<_> = data
314 .repos314 .repos
315 .iter()315 .iter()
316- .map(|row| (&row.name, row.kind.label(Lang::En), &row.last_ok, &row.error))316+ .map(|row| {
317+ (
318+ &row.name,
319+ row.kind.label(Lang::En),
320+ &row.last_ok,
321+ &row.error,
322+ )
323+ })
317 .collect();324 .collect();
318 Ok(format!(325 Ok(format!(
319 "{}|{}|{:?}|{:?}|{}|{:?}",326 "{}|{}|{:?}|{:?}|{}|{:?}",
crates/forge-web-account/src/pages/assets.rsmodified+35 -7
@@ -41,7 +41,11 @@ const CSS: &str = forge_web_app::build_info::MAIN_CSS;
41 /// Immutable when the URL carries the current content hash, so a changed file gets a new URL.41 /// Immutable when the URL carries the current content hash, so a changed file gets a new URL.
42 #[route(GET "/assets/main.css")]42 #[route(GET "/assets/main.css")]
43 async fn main_css(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {43 async fn main_css(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {
44- Ok(respond("text/css; charset=utf-8", cache_for(cx, STYLESHEET_HREF), CSS))44+ Ok(respond(
45+ "text/css; charset=utf-8",
46+ cache_for(cx, STYLESHEET_HREF),
47+ CSS,
48+ ))
45 }49 }
46 50
47 /// The soft-navigation script (`assets/nav.js`). Served from the same origin, so the CSP's51 /// The soft-navigation script (`assets/nav.js`). Served from the same origin, so the CSP's
@@ -51,7 +55,11 @@ const NAV_JS: &str = include_str!("../../../forge-web/assets/nav.js");
51 /// Immutable like `main.css`: the URL carries a content hash.55 /// Immutable like `main.css`: the URL carries a content hash.
52 #[route(GET "/assets/nav.js")]56 #[route(GET "/assets/nav.js")]
53 async fn nav_js(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {57 async fn nav_js(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {
54- Ok(respond("text/javascript; charset=utf-8", cache_for(cx, NAV_SCRIPT_HREF), NAV_JS))58+ Ok(respond(
59+ "text/javascript; charset=utf-8",
60+ cache_for(cx, NAV_SCRIPT_HREF),
61+ NAV_JS,
62+ ))
55 }63 }
56 64
57 /// Immutable like `main.css`: the URL carries a content hash.65 /// Immutable like `main.css`: the URL carries a content hash.
@@ -105,12 +113,20 @@ const OFFLINE_JS: &str = include_str!("../../../forge-web/assets/offline.js");
105 113
106 #[route(GET "/assets/offline.html")]114 #[route(GET "/assets/offline.html")]
107 async fn offline_html(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {115 async fn offline_html(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {
108- Ok(respond("text/html; charset=utf-8", "no-cache", OFFLINE_HTML))116+ Ok(respond(
117+ "text/html; charset=utf-8",
118+ "no-cache",
119+ OFFLINE_HTML,
120+ ))
109 }121 }
110 122
111 #[route(GET "/assets/offline.js")]123 #[route(GET "/assets/offline.js")]
112 async fn offline_js(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {124 async fn offline_js(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static str)> {
113- Ok(respond("text/javascript; charset=utf-8", "no-cache", OFFLINE_JS))125+ Ok(respond(
126+ "text/javascript; charset=utf-8",
127+ "no-cache",
128+ OFFLINE_JS,
129+ ))
114 }130 }
115 131
116 /// The stream every page and the offline page watch to learn that the server is back. It carries132 /// The stream every page and the offline page watch to learn that the server is back. It carries
@@ -190,17 +206,29 @@ async fn plex_mono_400_italic(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'stati
190 206
191 #[route(GET "/assets/fonts/Figtree-OFL.txt")]207 #[route(GET "/assets/fonts/Figtree-OFL.txt")]
192 async fn figtree_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {208 async fn figtree_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {
193- Ok(respond("text/plain; charset=utf-8", LICENSE_CACHE, FIGTREE_LICENSE))209+ Ok(respond(
210+ "text/plain; charset=utf-8",
211+ LICENSE_CACHE,
212+ FIGTREE_LICENSE,
213+ ))
194 }214 }
195 215
196 #[route(GET "/assets/fonts/Archivo-OFL.txt")]216 #[route(GET "/assets/fonts/Archivo-OFL.txt")]
197 async fn archivo_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {217 async fn archivo_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {
198- Ok(respond("text/plain; charset=utf-8", LICENSE_CACHE, ARCHIVO_LICENSE))218+ Ok(respond(
219+ "text/plain; charset=utf-8",
220+ LICENSE_CACHE,
221+ ARCHIVO_LICENSE,
222+ ))
199 }223 }
200 224
201 #[route(GET "/assets/fonts/IBMPlexMono-OFL.txt")]225 #[route(GET "/assets/fonts/IBMPlexMono-OFL.txt")]
202 async fn plex_mono_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {226 async fn plex_mono_license(cx: &Cx) -> Result<(StatusCode, HeaderMap, &'static [u8])> {
203- Ok(respond("text/plain; charset=utf-8", LICENSE_CACHE, PLEX_MONO_LICENSE))227+ Ok(respond(
228+ "text/plain; charset=utf-8",
229+ LICENSE_CACHE,
230+ PLEX_MONO_LICENSE,
231+ ))
204 }232 }
205 233
206 #[cfg(test)]234 #[cfg(test)]
crates/forge-web-account/src/pages/login.rsmodified+1 -1
@@ -2,8 +2,8 @@
2 2
3 use std::time::{Duration, Instant};3 use std::time::{Duration, Instant};
4 4
5-use forge_core::{AuditAction, User};
6 use forge_core::names::normalize_name;5 use forge_core::names::normalize_name;
6+use forge_core::{AuditAction, User};
7 use http::header::{HeaderValue, RETRY_AFTER};7 use http::header::{HeaderValue, RETRY_AFTER};
8 use serde::Deserialize;8 use serde::Deserialize;
9 use serde_json::json;9 use serde_json::json;
crates/forge-web-account/src/pages/new_repo.rsmodified+1 -1
@@ -7,9 +7,9 @@ use serde::Deserialize;
7 use topcoat::Result;7 use topcoat::Result;
8 use topcoat::context::{Cx, context};8 use topcoat::context::{Cx, context};
9 use topcoat::router::content::Form;9 use topcoat::router::content::Form;
10-use topcoat::router::error::see_other;
11 #[allow(unused_imports)]10 #[allow(unused_imports)]
12 use topcoat::router::error::bad_request;11 use topcoat::router::error::bad_request;
12+use topcoat::router::error::see_other;
13 use topcoat::router::{page, query_params};13 use topcoat::router::{page, query_params};
14 use topcoat::view::{View, component, view};14 use topcoat::view::{View, component, view};
15 15
crates/forge-web-account/src/pages/org_members.rsmodified+2 -2
@@ -19,8 +19,8 @@ use crate::audit::{self, Actor, Target};
19 use crate::i18n::orgs::{self as g, K};19 use crate::i18n::orgs::{self as g, K};
20 use crate::i18n::{self, Lang};20 use crate::i18n::{self, Lang};
21 use crate::pages::org_ctx::{21 use crate::pages::org_ctx::{
22- load_org, notice_href, org_notice, org_tab_counts, org_tabs, require_form_csrf,22+ load_org, notice_href, org_notice, org_tab_counts, org_tabs, require_form_csrf, require_member,
23- require_member, require_owner, take_notice,23+ require_owner, take_notice,
24 };24 };
25 use crate::state::AppState;25 use crate::state::AppState;
26 use crate::views::parts::{PeopleList, PersonRow, SubPart, head, people_list};26 use crate::views::parts::{PeopleList, PersonRow, SubPart, head, people_list};
crates/forge-web-account/src/pages/profile.rsmodified+7 -1
@@ -236,7 +236,13 @@ async fn profile_page(cx: &Cx) -> Result<impl View> {
236 let snippet_pages = snippet_total.div_ceil(PER_PAGE).max(1);236 let snippet_pages = snippet_total.div_ceil(PER_PAGE).max(1);
237 let snippet_page = page.min(snippet_pages);237 let snippet_page = page.min(snippet_pages);
238 let snippet_pager = pager_links(snippet_page, snippet_pages, |n| {238 let snippet_pager = pager_links(snippet_page, snippet_pages, |n| {
239- profile_href(&user.username, Tab::Snippets.key(), &Finder::default(), SORTS[0].0, n)239+ profile_href(
240+ &user.username,
241+ Tab::Snippets.key(),
242+ &Finder::default(),
243+ SORTS[0].0,
244+ n,
245+ )
240 });246 });
241 let snippets: Vec<ListRow> = snippets247 let snippets: Vec<ListRow> = snippets
242 .into_iter()248 .into_iter()
crates/forge-web-account/src/pages/releases_tests.rsmodified+2 -4
@@ -443,8 +443,7 @@ async fn creating_and_retagging_releases_take_tags_and_targets() {
443 draft: false,443 draft: false,
444 prerelease: false,444 prerelease: false,
445 };445 };
446- let refused =446+ let refused = release_ops::create(&fx.state, &fx.repo, &fx.tahinli, input("a/b", "main")).await;
447- release_ops::create(&fx.state, &fx.repo, &fx.tahinli, input("a/b", "main")).await;
448 assert!(447 assert!(
449 matches!(refused, Err(ReleaseError::Invalid(_))),448 matches!(refused, Err(ReleaseError::Invalid(_))),
450 "bad tag: {refused:?}"449 "bad tag: {refused:?}"
@@ -539,8 +538,7 @@ async fn creating_and_retagging_releases_take_tags_and_targets() {
539 target: Some("next".to_owned()),538 target: Some("next".to_owned()),
540 ..keep(&draft)539 ..keep(&draft)
541 };540 };
542- let refused =541+ let refused = release_ops::update(&fx.state, &fx.repo, &fx.tahinli, &draft, clash_target).await;
543- release_ops::update(&fx.state, &fx.repo, &fx.tahinli, &draft, clash_target).await;
544 assert!(542 assert!(
545 matches!(refused, Err(ReleaseError::Invalid(_))),543 matches!(refused, Err(ReleaseError::Invalid(_))),
546 "{refused:?}"544 "{refused:?}"
crates/forge-web-account/src/pages/settings_appearance.rsmodified+5 -1
@@ -740,7 +740,11 @@ mod tests {
740 assert_eq!(accent_row.stripe.hue, plum_hue, "preset accent: knob hue");740 assert_eq!(accent_row.stripe.hue, plum_hue, "preset accent: knob hue");
741 assert!(!base_row.stripe.custom, "preset base: not custom");741 assert!(!base_row.stripe.custom, "preset base: not custom");
742 assert_eq!(base_row.stripe.hue, ink_hue, "preset base: knob hue");742 assert_eq!(base_row.stripe.hue, ink_hue, "preset base: knob hue");
743- let plum = accent_row.choices.iter().find(|c| c.value == "plum").unwrap();743+ let plum = accent_row
744+ .choices
745+ .iter()
746+ .find(|c| c.value == "plum")
747+ .unwrap();
744 assert!(plum.selected, "preset accent: checked");748 assert!(plum.selected, "preset accent: checked");
745 assert_eq!(plum.hue, plum_hue.to_string(), "preset accent: hue value");749 assert_eq!(plum.hue, plum_hue.to_string(), "preset accent: hue value");
746 750
crates/forge-web-account/src/pages/settings_gpg.rsmodified+1 -1
@@ -15,7 +15,7 @@ use crate::audit::{self, Actor, Target};
15 use crate::auth::require_csrf;15 use crate::auth::require_csrf;
16 use crate::i18n::s;16 use crate::i18n::s;
17 use crate::i18n::{self, Key, Lang, t};17 use crate::i18n::{self, Key, Lang, t};
18-use crate::pages::settings_keys::{KeyKind, KeysDraft, kind_page, keys_page_view};18+use crate::pages::settings_keys::{KeyKind, KeysDraft, keys_page_view, kind_page};
19 use crate::signatures;19 use crate::signatures;
20 use crate::state::AppState;20 use crate::state::AppState;
21 use crate::views::parts::confirm_act;21 use crate::views::parts::confirm_act;
crates/forge-web-account/src/pages/settings_tokens.rsmodified+1 -1
@@ -23,7 +23,7 @@ use crate::i18n::packages::{self as pk, K as PK};
23 use crate::i18n::releases_ci::{self as rc, K as RC};23 use crate::i18n::releases_ci::{self as rc, K as RC};
24 use crate::i18n::s;24 use crate::i18n::s;
25 use crate::i18n::{self, Key, Lang, t, token_name_length};25 use crate::i18n::{self, Key, Lang, t, token_name_length};
26-use crate::pages::settings_keys::{KeyKind, KeysDraft, kind_page, keys_page_view};26+use crate::pages::settings_keys::{KeyKind, KeysDraft, keys_page_view, kind_page};
27 use crate::state::AppState;27 use crate::state::AppState;
28 use crate::views::parts::confirm_act;28 use crate::views::parts::confirm_act;
29 use crate::views::{alert, rel_time, rel_time_or_never};29 use crate::views::{alert, rel_time, rel_time_or_never};
crates/forge-web-app/src/alerts.rsmodified+20 -5
@@ -86,9 +86,10 @@ impl AlertTopic {
86 fn kind(self) -> AlertKind {86 fn kind(self) -> AlertKind {
87 match self {87 match self {
88 Self::RunnerOffline => AlertKind::RunnerOffline,88 Self::RunnerOffline => AlertKind::RunnerOffline,
89- Self::BackupFailed | Self::BackupVerifyFailed | Self::BackupOverdue | Self::FsckFailed => {89+ Self::BackupFailed
90- AlertKind::Backup90+ | Self::BackupVerifyFailed
91- }91+ | Self::BackupOverdue
92+ | Self::FsckFailed => AlertKind::Backup,
92 Self::DiskLow => AlertKind::Disk,93 Self::DiskLow => AlertKind::Disk,
93 Self::CiKilled => AlertKind::CiKilled,94 Self::CiKilled => AlertKind::CiKilled,
94 Self::SelfUpdateRestart | Self::SelfUpdateFailed => AlertKind::SelfUpdate,95 Self::SelfUpdateRestart | Self::SelfUpdateFailed => AlertKind::SelfUpdate,
@@ -491,7 +492,14 @@ async fn check_backup_overdue(state: &AppState, now: i64) {
491 || "never".to_owned(),492 || "never".to_owned(),
492 |t| forge_core::tz::format_in_tz(t, "UTC"),493 |t| forge_core::tz::format_in_tz(t, "UTC"),
493 );494 );
494- raise(state, AlertTopic::BackupOverdue, "backup_overdue", "", &detail).await;495+ raise(
496+ state,
497+ AlertTopic::BackupOverdue,
498+ "backup_overdue",
499+ "",
500+ &detail,
501+ )
502+ .await;
495 } else {503 } else {
496 resolve(state, "backup_overdue").await;504 resolve(state, "backup_overdue").await;
497 }505 }
@@ -634,7 +642,14 @@ mod tests {
634 642
635 config.alerts.enabled = false;643 config.alerts.enabled = false;
636 state.set_config(config);644 state.set_config(config);
637- raise(&state, AlertTopic::BackupFailed, "backup_failed", "", "boom").await;645+ raise(
646+ &state,
647+ AlertTopic::BackupFailed,
648+ "backup_failed",
649+ "",
650+ "boom",
651+ )
652+ .await;
638 assert_eq!(653 assert_eq!(
639 inbox(&state, &tahinli).await.len(),654 inbox(&state, &tahinli).await.len(),
640 1,655 1,
crates/forge-web-app/src/api/releases.rsmodified+25 -60
@@ -132,18 +132,11 @@ async fn get_release_by_tag(cx: &Cx) -> topcoat::Result<Response> {
132 #[route(POST "/api/v1/repos/{owner}/{repo}/releases")]132 #[route(POST "/api/v1/repos/{owner}/{repo}/releases")]
133 async fn create_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {133 async fn create_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {
134 let state = context::<AppState>(cx);134 let state = context::<AppState>(cx);
135- let (repo, user) = match api::load_writer(135+ let (repo, user) =
136- state,136+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
137- client_ip(cx),137+ Ok(found) => found,
138- headers(cx),138+ Err(res) => return Ok(*res),
139- owner(cx),139+ };
140- repo(cx),
141- )
142- .await
143- {
144- Ok(found) => found,
145- Err(res) => return Ok(*res),
146- };
147 let input: CreateBody = match api::json_body(body, MAX_JSON_BYTES).await {140 let input: CreateBody = match api::json_body(body, MAX_JSON_BYTES).await {
148 Ok(input) => input,141 Ok(input) => input,
149 Err(res) => return Ok(*res),142 Err(res) => return Ok(*res),
@@ -176,18 +169,11 @@ async fn create_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {
176 #[route(PATCH "/api/v1/repos/{owner}/{repo}/releases/{id}")]169 #[route(PATCH "/api/v1/repos/{owner}/{repo}/releases/{id}")]
177 async fn edit_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {170 async fn edit_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {
178 let state = context::<AppState>(cx);171 let state = context::<AppState>(cx);
179- let (repo, user) = match api::load_writer(172+ let (repo, user) =
180- state,173+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
181- client_ip(cx),174+ Ok(found) => found,
182- headers(cx),175+ Err(res) => return Ok(*res),
183- owner(cx),176+ };
184- repo(cx),
185- )
186- .await
187- {
188- Ok(found) => found,
189- Err(res) => return Ok(*res),
190- };
191 let release = match release_in_repo(state, &repo, id(cx)).await {177 let release = match release_in_repo(state, &repo, id(cx)).await {
192 Ok(release) => release,178 Ok(release) => release,
193 Err(res) => return Ok(*res),179 Err(res) => return Ok(*res),
@@ -217,18 +203,11 @@ async fn edit_release(cx: &Cx, body: Body) -> topcoat::Result<Response> {
217 #[route(DELETE "/api/v1/repos/{owner}/{repo}/releases/{id}")]203 #[route(DELETE "/api/v1/repos/{owner}/{repo}/releases/{id}")]
218 async fn delete_release(cx: &Cx) -> topcoat::Result<Response> {204 async fn delete_release(cx: &Cx) -> topcoat::Result<Response> {
219 let state = context::<AppState>(cx);205 let state = context::<AppState>(cx);
220- let (repo, user) = match api::load_writer(206+ let (repo, user) =
221- state,207+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
222- client_ip(cx),208+ Ok(found) => found,
223- headers(cx),209+ Err(res) => return Ok(*res),
224- owner(cx),210+ };
225- repo(cx),
226- )
227- .await
228- {
229- Ok(found) => found,
230- Err(res) => return Ok(*res),
231- };
232 let release = match release_in_repo(state, &repo, id(cx)).await {211 let release = match release_in_repo(state, &repo, id(cx)).await {
233 Ok(release) => release,212 Ok(release) => release,
234 Err(res) => return Ok(*res),213 Err(res) => return Ok(*res),
@@ -243,18 +222,11 @@ async fn delete_release(cx: &Cx) -> topcoat::Result<Response> {
243 #[route(PUT "/api/v1/repos/{owner}/{repo}/releases/{id}/assets/{asset}")]222 #[route(PUT "/api/v1/repos/{owner}/{repo}/releases/{id}/assets/{asset}")]
244 async fn upload_asset(cx: &Cx, body: Body) -> topcoat::Result<Response> {223 async fn upload_asset(cx: &Cx, body: Body) -> topcoat::Result<Response> {
245 let state = context::<AppState>(cx);224 let state = context::<AppState>(cx);
246- let (repo, user) = match api::load_writer(225+ let (repo, user) =
247- state,226+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
248- client_ip(cx),227+ Ok(found) => found,
249- headers(cx),228+ Err(res) => return Ok(*res),
250- owner(cx),229+ };
251- repo(cx),
252- )
253- .await
254- {
255- Ok(found) => found,
256- Err(res) => return Ok(*res),
257- };
258 let release = match release_in_repo(state, &repo, id(cx)).await {230 let release = match release_in_repo(state, &repo, id(cx)).await {
259 Ok(release) => release,231 Ok(release) => release,
260 Err(res) => return Ok(*res),232 Err(res) => return Ok(*res),
@@ -302,18 +274,11 @@ async fn upload_asset(cx: &Cx, body: Body) -> topcoat::Result<Response> {
302 #[route(DELETE "/api/v1/repos/{owner}/{repo}/releases/{id}/assets/{asset}")]274 #[route(DELETE "/api/v1/repos/{owner}/{repo}/releases/{id}/assets/{asset}")]
303 async fn delete_asset(cx: &Cx) -> topcoat::Result<Response> {275 async fn delete_asset(cx: &Cx) -> topcoat::Result<Response> {
304 let state = context::<AppState>(cx);276 let state = context::<AppState>(cx);
305- let (repo, _user) = match api::load_writer(277+ let (repo, _user) =
306- state,278+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
307- client_ip(cx),279+ Ok(found) => found,
308- headers(cx),280+ Err(res) => return Ok(*res),
309- owner(cx),281+ };
310- repo(cx),
311- )
312- .await
313- {
314- Ok(found) => found,
315- Err(res) => return Ok(*res),
316- };
317 let release = match release_in_repo(state, &repo, id(cx)).await {282 let release = match release_in_repo(state, &repo, id(cx)).await {
318 Ok(release) => release,283 Ok(release) => release,
319 Err(res) => return Ok(*res),284 Err(res) => return Ok(*res),
crates/forge-web-app/src/api/statuses.rsmodified+5 -12
@@ -36,18 +36,11 @@ struct ReportBody {
36 #[route(POST "/api/v1/repos/{owner}/{repo}/statuses/{sha}")]36 #[route(POST "/api/v1/repos/{owner}/{repo}/statuses/{sha}")]
37 async fn report_status(cx: &Cx, body: Body) -> topcoat::Result<Response> {37 async fn report_status(cx: &Cx, body: Body) -> topcoat::Result<Response> {
38 let state = context::<AppState>(cx);38 let state = context::<AppState>(cx);
39- let (repo, user) = match api::load_writer(39+ let (repo, user) =
40- state,40+ match api::load_writer(state, client_ip(cx), headers(cx), owner(cx), repo(cx)).await {
41- client_ip(cx),41+ Ok(found) => found,
42- headers(cx),42+ Err(res) => return Ok(*res),
43- owner(cx),43+ };
44- repo(cx),
45- )
46- .await
47- {
48- Ok(found) => found,
49- Err(res) => return Ok(*res),
50- };
51 let Some(sha) = api::normalize_sha(sha(cx)) else {44 let Some(sha) = api::normalize_sha(sha(cx)) else {
52 return Ok(not_a_full_sha());45 return Ok(not_a_full_sha());
53 };46 };
crates/forge-web-app/src/backup/mod.rsmodified+1 -1
@@ -17,8 +17,8 @@ use std::fs::{DirBuilder, File};
17 use std::os::unix::fs::{DirBuilderExt, OpenOptionsExt, PermissionsExt};17 use std::os::unix::fs::{DirBuilderExt, OpenOptionsExt, PermissionsExt};
18 use std::path::{Path, PathBuf};18 use std::path::{Path, PathBuf};
19 19
20-use forge_core::{Error, Result, Store};
21 use forge_core::token::sha256_reader;20 use forge_core::token::sha256_reader;
21+use forge_core::{Error, Result, Store};
22 use forge_git::GitEnv;22 use forge_git::GitEnv;
23 use serde::{Deserialize, Serialize};23 use serde::{Deserialize, Serialize};
24 use sha2::{Digest, Sha256};24 use sha2::{Digest, Sha256};
crates/forge-web-app/src/backup/scheduler.rsmodified+9 -1
@@ -306,7 +306,15 @@ pub async fn fsck_job(state: &AppState, trigger: RunTrigger, full: bool) -> Resu
306 Err(e) => Some(e.to_string()),306 Err(e) => Some(e.to_string()),
307 };307 };
308 crate::alerts::fsck_finished(state, problem.as_deref().map_or(Ok(()), Err)).await;308 crate::alerts::fsck_finished(state, problem.as_deref().map_or(Ok(()), Err)).await;
309- record_finish(state, &run_id, problem.is_none(), None, None, problem.as_deref()).await;309+ record_finish(
310+ state,
311+ &run_id,
312+ problem.is_none(),
313+ None,
314+ None,
315+ problem.as_deref(),
316+ )
317+ .await;
310 outcome318 outcome
311 }319 }
312 320
crates/forge-web-app/src/ci/api.rsmodified+7 -4
@@ -807,9 +807,7 @@ async fn append_log(cx: &Cx, body: Body) -> topcoat::Result<Response> {
807 Err(res) => return Ok(*res),807 Err(res) => return Ok(*res),
808 };808 };
809 match write_log(state, &job, offset, &chunk).await {809 match write_log(state, &job, offset, &chunk).await {
810- Ok(LogWrite::Stored(size)) => {810+ Ok(LogWrite::Stored(size)) => Ok(api::json(StatusCode::OK, &json!({ "size": size }))),
811- Ok(api::json(StatusCode::OK, &json!({ "size": size })))
812- }
813 Ok(LogWrite::Mismatch(size)) => {811 Ok(LogWrite::Mismatch(size)) => {
814 let mut res = api::error(StatusCode::CONFLICT, "the log offset does not match");812 let mut res = api::error(StatusCode::CONFLICT, "the log offset does not match");
815 res.headers_mut().insert(813 res.headers_mut().insert(
@@ -831,7 +829,12 @@ async fn write_log(
831 chunk: &[u8],829 chunk: &[u8],
832 ) -> Result<LogWrite, Refusal> {830 ) -> Result<LogWrite, Refusal> {
833 let _guard = LOG_LOCK.lock().await;831 let _guard = LOG_LOCK.lock().await;
834- let size = match state.store.job_by_id(&job.id).await.map_err(api::internal)? {832+ let size = match state
833+ .store
834+ .job_by_id(&job.id)
835+ .await
836+ .map_err(api::internal)?
837+ {
835 Some(fresh) => u64::try_from(fresh.log_bytes).unwrap_or(0),838 Some(fresh) => u64::try_from(fresh.log_bytes).unwrap_or(0),
836 None => return Err(api::internal("log for a job that is gone")),839 None => return Err(api::internal("log for a job that is gone")),
837 };840 };
crates/forge-web-app/src/ci/api_tests.rsmodified+0 -1
@@ -1207,7 +1207,6 @@ async fn job_token_reads_over_smart_http_but_never_pushes() {
1207 );1207 );
1208 }1208 }
1209 1209
1210-
1211 #[tokio::test]1210 #[tokio::test]
1212 async fn runner_binary_needs_runner_auth_and_self_update() {1211 async fn runner_binary_needs_runner_auth_and_self_update() {
1213 let env = bare(|_| {}).await;1212 let env = bare(|_| {}).await;
crates/forge-web-app/src/importer/mod.rsmodified+8 -2
@@ -889,8 +889,14 @@ impl<A: RemoteApi> Run<'_, A> {
889 )889 )
890 .await?;890 .await?;
891 let kind = if item.is_pr { "pull" } else { "issue" };891 let kind = if item.is_pr { "pull" } else { "issue" };
892- self.record(kind, &item.number.to_string(), &issue.id, &item.author, &item.url)892+ self.record(
893- .await;893+ kind,
894+ &item.number.to_string(),
895+ &issue.id,
896+ &item.author,
897+ &item.url,
898+ )
899+ .await;
894 let mut ids = Vec::new();900 let mut ids = Vec::new();
895 for name in &item.labels {901 for name in &item.labels {
896 if let Some(id) = self.label_id(labels, name, FALLBACK_LABEL_COLOR).await {902 if let Some(id) = self.label_id(labels, name, FALLBACK_LABEL_COLOR).await {
crates/forge-web-app/src/layers.rsmodified+1 -1
@@ -1,8 +1,8 @@
1 use std::fmt;1 use std::fmt;
2 2
3 use topcoat::context::Cx;3 use topcoat::context::Cx;
4-use topcoat::router::request::{method, uri};
5 use topcoat::router::Method;4 use topcoat::router::Method;
5+use topcoat::router::request::{method, uri};
6 6
7 use crate::live::Topic;7 use crate::live::Topic;
8 use crate::state::AppState;8 use crate::state::AppState;
crates/forge-web-app/src/mail/worker.rsmodified+5 -1
@@ -74,7 +74,11 @@ async fn tick(state: &AppState) -> forge_core::Result<Duration> {
74 deliver(state, &entry).await;74 deliver(state, &entry).await;
75 }75 }
76 let next = state.store.next_mail_due().await?;76 let next = state.store.next_mail_due().await?;
77- Ok(sleep_until(next.as_deref(), OffsetDateTime::now_utc(), BACKSTOP))77+ Ok(sleep_until(
78+ next.as_deref(),
79+ OffsetDateTime::now_utc(),
80+ BACKSTOP,
81+ ))
78 }82 }
79 83
80 /// Sends one leased message and records the outcome.84 /// Sends one leased message and records the outcome.
crates/forge-web-app/src/raw/media.rsmodified+7 -7
@@ -14,8 +14,8 @@ use topcoat::router::{
14 use crate::lfs::{has_object, object_path};14 use crate::lfs::{has_object, object_path};
15 use crate::lfs_pointer;15 use crate::lfs_pointer;
16 use crate::raw::{16 use crate::raw::{
17- CACHE_NONE, Lookup, Meta, OCTET, TokenQuery, encode_path, finish, lookup, plain,17+ CACHE_NONE, Lookup, Meta, OCTET, TokenQuery, encode_path, finish, lookup, plain, resolve_repo,
18- resolve_repo, signed_url,18+ signed_url,
19 };19 };
20 use crate::state::AppState;20 use crate::state::AppState;
21 21
@@ -51,11 +51,11 @@ async fn serve(cx: &Cx) -> Response {
51 .ok()51 .ok()
52 .and_then(|query| query.token);52 .and_then(|query| query.token);
53 53
54- let (repo, repo_dir, cache) =54+ let (repo, repo_dir, cache) = match resolve_repo(&state, &owner, &name, token.as_deref()).await
55- match resolve_repo(&state, &owner, &name, token.as_deref()).await {55+ {
56- Ok(found) => found,56+ Ok(found) => found,
57- Err(response) => return response,57+ Err(response) => return response,
58- };58+ };
59 59
60 let looked = tokio::task::spawn_blocking(move || lookup(&repo_dir, &rest, None)).await;60 let looked = tokio::task::spawn_blocking(move || lookup(&repo_dir, &rest, None)).await;
61 let data = match looked {61 let data = match looked {
crates/forge-web-app/src/raw/snippet_raw.rsmodified+2 -2
@@ -10,8 +10,8 @@ use topcoat::router::{
10 };10 };
11 11
12 use crate::raw::{12 use crate::raw::{
13- CACHE_NONE, CACHE_PRIVATE, CACHE_PUBLIC, Meta, TEXT, TokenQuery, encode_path, finish,13+ CACHE_NONE, CACHE_PRIVATE, CACHE_PUBLIC, Meta, TEXT, TokenQuery, encode_path, finish, now_unix,
14- now_unix, plain, signed_url,14+ plain, signed_url,
15 };15 };
16 use crate::state::AppState;16 use crate::state::AppState;
17 17
crates/forge-web-app/src/web_push/mod.rsmodified+4 -1
@@ -54,7 +54,10 @@ pub enum Alert {
54 count: u64,54 count: u64,
55 url: String,55 url: String,
56 },56 },
57- Admin { subject: String, detail: String },57+ Admin {
58+ subject: String,
59+ detail: String,
60+ },
58 Test,61 Test,
59 }62 }
60 63
crates/forge-web-base/src/accent.rsmodified+1 -4
@@ -35,10 +35,7 @@ pub fn ids() -> impl Iterator<Item = &'static str> {
35 /// The preset base for a stored id. An unknown or removed id, and a `hue-N` id, fall back to the35 /// The preset base for a stored id. An unknown or removed id, and a `hue-N` id, fall back to the
36 /// default. A page shows `base_id` instead, which keeps a hue.36 /// default. A page shows `base_id` instead, which keeps a hue.
37 pub fn resolve_base(stored: &str) -> &'static Base {37 pub fn resolve_base(stored: &str) -> &'static Base {
38- BASES38+ BASES.iter().find(|b| b.id == stored).unwrap_or(&BASES[0])
39- .iter()
40- .find(|b| b.id == stored)
41- .unwrap_or(&BASES[0])
42 }39 }
43 40
44 /// The base id a page shows for a stored one: the id itself when forge offers it (a preset or a41 /// The base id a page shows for a stored one: the id itself when forge offers it (a preset or a
crates/forge-web-pages/src/pages/admin_runners.rsmodified+12 -3
@@ -1088,8 +1088,14 @@ async fn runner_job_rows(
1088 .iter()1088 .iter()
1089 .partition(|job| job.job.state == JobState::Running);1089 .partition(|job| job.job.state == JobState::Running);
1090 Ok((1090 Ok((
1091- running.into_iter().map(|job| runner_job_row(lang, job)).collect(),1091+ running
1092- finished.into_iter().map(|job| runner_job_row(lang, job)).collect(),1092+ .into_iter()
1093+ .map(|job| runner_job_row(lang, job))
1094+ .collect(),
1095+ finished
1096+ .into_iter()
1097+ .map(|job| runner_job_row(lang, job))
1098+ .collect(),
1093 ))1099 ))
1094 }1100 }
1095 1101
@@ -1358,7 +1364,10 @@ fn metrics_view(lang: Lang, samples: &[RunnerSample], now_ms: i64) -> MetricsVie
1358 let net = mx_chart(1364 let net = mx_chart(
1359 &points,1365 &points,
1360 net_top,1366 net_top,
1361- &[(|b: &Bucket| b.rx, "mx-line"), (|b: &Bucket| b.tx, "mx-line mx-line-sent")],1367+ &[
1368+ (|b: &Bucket| b.rx, "mx-line"),
1369+ (|b: &Bucket| b.tx, "mx-line mx-line-sent"),
1370+ ],
1362 false,1371 false,
1363 &rate_text,1372 &rate_text,
1364 &|b| {1373 &|b| {
crates/forge-web-pages/src/pages/ci_runs.rsmodified+6 -1
@@ -3051,7 +3051,12 @@ async fn run_artifacts_zip(cx: &Cx) -> Result<Response> {
3051 .map_err(forge_core::Error::Io)?;3051 .map_err(forge_core::Error::Io)?;
3052 let mut res = Response::new(topcoat::router::Body::from(zipped));3052 let mut res = Response::new(topcoat::router::Body::from(zipped));
3053 let file = format!("{}-run-{}-artifacts.zip", ctx.repo.name, run.number);3053 let file = format!("{}-run-{}-artifacts.zip", ctx.repo.name, run.number);
3054- attachment_headers(res.headers_mut(), "application/zip", &file, "private, no-cache");3054+ attachment_headers(
3055+ res.headers_mut(),
3056+ "application/zip",
3057+ &file,
3058+ "private, no-cache",
3059+ );
3055 Ok(res)3060 Ok(res)
3056 }3061 }
3057 3062
crates/forge-web-pages/src/pages/edit_history.rsmodified+6 -1
@@ -63,7 +63,12 @@ pub async fn thread_edit_counts(
63 .flat_map(|thread| std::iter::once(&thread.root).chain(thread.replies.iter()))63 .flat_map(|thread| std::iter::once(&thread.root).chain(thread.replies.iter()))
64 .map(|comment| comment.id.as_str())64 .map(|comment| comment.id.as_str())
65 .collect();65 .collect();
66- Ok(Arc::new(state.store.edit_count(EditTarget::ReviewComment, &ids).await?))66+ Ok(Arc::new(
67+ state
68+ .store
69+ .edit_count(EditTarget::ReviewComment, &ids)
70+ .await?,
71+ ))
67 }72 }
68 73
69 /// One line of a diff: its CSS class from the `diff-*` set and its text with its sign.74 /// One line of a diff: its CSS class from the `diff-*` set and its text with its sign.
crates/forge-web-pages/src/pages/issue_parts.rsmodified+18 -12
@@ -61,7 +61,6 @@ impl ItemKind {
61 }61 }
62 }62 }
63 63
64-
65 pub fn viewer(ctx: &RepoCtx) -> Option<&User> {64 pub fn viewer(ctx: &RepoCtx) -> Option<&User> {
66 ctx.viewer.as_ref().map(|(user, _)| user)65 ctx.viewer.as_ref().map(|(user, _)| user)
67 }66 }
@@ -124,7 +123,6 @@ pub fn csrf_of(ctx: &RepoCtx) -> String {
124 .unwrap_or_default()123 .unwrap_or_default()
125 }124 }
126 125
127-
128 /// Parses an issue number: digits only, greater than zero. Anything else is 404.126 /// Parses an issue number: digits only, greater than zero. Anything else is 404.
129 pub fn parse_number(raw: &str) -> Result<i64> {127 pub fn parse_number(raw: &str) -> Result<i64> {
130 match raw.parse::<i64>() {128 match raw.parse::<i64>() {
@@ -188,7 +186,6 @@ pub async fn reachable_among(path: &std::path::Path, oids: Vec<String>) -> HashS
188 .unwrap_or_default()186 .unwrap_or_default()
189 }187 }
190 188
191-
192 /// One comment, or the item body (which uses the same item shape without a delete action).189 /// One comment, or the item body (which uses the same item shape without a delete action).
193 pub struct CommentView {190 pub struct CommentView {
194 anchor: String,191 anchor: String,
@@ -761,7 +758,10 @@ pub async fn load_discussion(
761 };758 };
762 let body_anchor = kind.anchor(number);759 let body_anchor = kind.anchor(number);
763 let opened = When::new(lang, &item.created_at, &tz, now);760 let opened = When::new(lang, &item.created_at, &tz, now);
764- let body_edits = state.store.edit_count(EditTarget::Issue, &[item.id.as_str()]).await?;761+ let body_edits = state
762+ .store
763+ .edit_count(EditTarget::Issue, &[item.id.as_str()])
764+ .await?;
765 let body_history = body_edits765 let body_history = body_edits
766 .get(&item.id)766 .get(&item.id)
767 .is_some_and(|count| *count > 0)767 .is_some_and(|count| *count > 0)
@@ -795,7 +795,10 @@ pub async fn load_discussion(
795 };795 };
796 796
797 let comment_ids: Vec<&str> = comments.iter().map(|c| c.id.as_str()).collect();797 let comment_ids: Vec<&str> = comments.iter().map(|c| c.id.as_str()).collect();
798- let comment_edits = state.store.edit_count(EditTarget::Comment, &comment_ids).await?;798+ let comment_edits = state
799+ .store
800+ .edit_count(EditTarget::Comment, &comment_ids)
801+ .await?;
799 let mut keyed: Vec<(String, Entry)> = Vec::new();802 let mut keyed: Vec<(String, Entry)> = Vec::new();
800 for comment in comments {803 for comment in comments {
801 let (who_name, hash) = who(&comment.author_id);804 let (who_name, hash) = who(&comment.author_id);
@@ -811,10 +814,16 @@ pub async fn load_discussion(
811 avatar: avatar_url(&who_name, hash.as_deref()),814 avatar: avatar_url(&who_name, hash.as_deref()),
812 when: When::new(lang, &comment.created_at, &tz, now),815 when: When::new(lang, &comment.created_at, &tz, now),
813 html: render_markdown(&comment.body, Some(&link)),816 html: render_markdown(&comment.body, Some(&link)),
814- history_href: edited817+ history_href: edited.then(|| {
815- .then(|| {818+ history_href(
816- history_href(&owner, &name, kind, number, EditTarget::Comment, &comment.id)819+ &owner,
817- }),820+ &name,
821+ kind,
822+ number,
823+ EditTarget::Comment,
824+ &comment.id,
825+ )
826+ }),
818 edit_href: mine827 edit_href: mine
819 .then(|| repo_href(&owner, &name, segment, &format!("{comment_path}/edit"))),828 .then(|| repo_href(&owner, &name, segment, &format!("{comment_path}/edit"))),
820 delete_href: mine829 delete_href: mine
@@ -1106,7 +1115,6 @@ async fn review_entries(
1106 Ok(keyed)1115 Ok(keyed)
1107 }1116 }
1108 1117
1109-
1110 pub struct LabelRow {1118 pub struct LabelRow {
1111 id: String,1119 id: String,
1112 name: String,1120 name: String,
@@ -1443,7 +1451,6 @@ pub async fn item_sidebar(
1443 })1451 })
1444 }1452 }
1445 1453
1446-
1447 /// The id of the comment form. The head's Close and Reopen buttons post it with `form=`, so a1454 /// The id of the comment form. The head's Close and Reopen buttons post it with `form=`, so a
1448 /// close can carry the draft text as its comment, as it always did.1455 /// close can carry the draft text as its comment, as it always did.
1449 pub const COMMENT_FORM: &str = "item-comment";1456 pub const COMMENT_FORM: &str = "item-comment";
@@ -1509,7 +1516,6 @@ pub async fn comment_form(
1509 })1516 })
1510 }1517 }
1511 1518
1512-
1513 /// The form fields of a comment or state POST.1519 /// The form fields of a comment or state POST.
1514 #[derive(Deserialize)]1520 #[derive(Deserialize)]
1515 pub struct CommentForm {1521 pub struct CommentForm {
crates/forge-web-pages/src/pages/issues_list.rsmodified+2 -2
@@ -912,8 +912,8 @@ async fn new_issue_submit(cx: &Cx, RawForm(raw): RawForm) -> Result<impl View> {
912 .await?;912 .await?;
913 if can_triage(&ctx)913 if can_triage(&ctx)
914 && !picked.is_empty()914 && !picked.is_empty()
915- && let Err(e) = set_picked_labels(state, &ctx.repo.id, &issue.id, &viewer.0.id, &picked)915+ && let Err(e) =
916- .await916+ set_picked_labels(state, &ctx.repo.id, &issue.id, &viewer.0.id, &picked).await
917 {917 {
918 tracing::error!(error = %e, issue_id = %issue.id, "new issue: labels not set");918 tracing::error!(error = %e, issue_id = %issue.id, "new issue: labels not set");
919 }919 }
crates/forge-web-pages/src/pages/packages.rsmodified+5 -1
@@ -293,7 +293,11 @@ async fn package_view(cx: &Cx, page: PackagePage) -> Result<impl View> {
293 let has_versions = !versions.is_empty();293 let has_versions = !versions.is_empty();
294 let install = pk::t(lang, K::Install);294 let install = pk::t(lang, K::Install);
295 let install_cmds = [295 let install_cmds = [
296- (pk::t(lang, K::InstallRegistryConfig), "pkg-config", config_block),296+ (
297+ pk::t(lang, K::InstallRegistryConfig),
298+ "pkg-config",
299+ config_block,
300+ ),
297 (pk::t(lang, K::InstallAdd), "pkg-add", add_cmd),301 (pk::t(lang, K::InstallAdd), "pkg-add", add_cmd),
298 (pk::t(lang, K::InstallPublish), "pkg-publish", publish_cmd),302 (pk::t(lang, K::InstallPublish), "pkg-publish", publish_cmd),
299 (pk::t(lang, K::InstallLogin), "pkg-login", login_cmd),303 (pk::t(lang, K::InstallLogin), "pkg-login", login_cmd),
crates/forge-web-repo/src/pages/authoring_tests.rsmodified+5 -1
@@ -206,7 +206,11 @@ async fn scenario_task_toggles(fx: &Fixture) {
206 .unwrap()206 .unwrap()
207 .unwrap();207 .unwrap();
208 assert_eq!(now.body, "- [ ] one\n- [x] two\n");208 assert_eq!(now.body, "- [ ] one\n- [x] two\n");
209- let history = fx.store.edit_history(EditTarget::Issue, &issue.id).await.unwrap();209+ let history = fx
210+ .store
211+ .edit_history(EditTarget::Issue, &issue.id)
212+ .await
213+ .unwrap();
210 assert_eq!(history.len(), 1);214 assert_eq!(history.len(), 1);
211 assert_eq!(history[0].old_body, "- [ ] one\n- [ ] two\n");215 assert_eq!(history[0].old_body, "- [ ] one\n- [ ] two\n");
212 216
crates/forge-web-repo/src/pages/commits.rsmodified+1 -1
@@ -363,8 +363,8 @@ mod tests {
363 363
364 use crate::i18n::Lang;364 use crate::i18n::Lang;
365 use crate::test_support::fixture::{Fixture, OWNER, REPO, get, git};365 use crate::test_support::fixture::{Fixture, OWNER, REPO, get, git};
366- use crate::views::relative_time;
367 use crate::views::enc;366 use crate::views::enc;
367+ use crate::views::relative_time;
368 368
369 #[test]369 #[test]
370 fn dates_and_relative_units_format() {370 fn dates_and_relative_units_format() {
crates/forge-web-repo/src/pages/pull_branch.rsmodified+4 -6
@@ -156,9 +156,7 @@ async fn head_writable(
156 Ok(!head.archived && authorize(Some(user), head, role, org_role, Action::Write).is_ok())156 Ok(!head.archived && authorize(Some(user), head, role, org_role, Action::Write).is_ok())
157 }157 }
158 158
159-fn cas_refusal(159+fn cas_refusal(result: forge_git::error::Result<()>) -> forge_core::Result<Option<&'static str>> {
160- result: forge_git::error::Result<()>,
161-) -> forge_core::Result<Option<&'static str>> {
162 match result {160 match result {
163 Ok(()) => Ok(None),161 Ok(()) => Ok(None),
164 Err(forge_git::error::Error::RefMoved(_)) => Ok(Some(ERR_MOVED)),162 Err(forge_git::error::Error::RefMoved(_)) => Ok(Some(ERR_MOVED)),
@@ -231,9 +229,9 @@ async fn restore_branch(
231 if read_commit(&path, &pr.head_oid)?.is_none() {229 if read_commit(&path, &pr.head_oid)?.is_none() {
232 return Ok(Some(ERR_MISSING));230 return Ok(Some(ERR_MISSING));
233 }231 }
234- if let Some(code) = cas_refusal(232+ if let Some(code) =
235- update_ref_cas(&state.git, &path, &refname, &pr.head_oid, ZERO_OID).await,233+ cas_refusal(update_ref_cas(&state.git, &path, &refname, &pr.head_oid, ZERO_OID).await)?
236- )? {234+ {
237 return Ok(Some(code));235 return Ok(Some(code));
238 }236 }
239 record_ref_change(state, head, user, &refname, ZERO_OID, &pr.head_oid).await;237 record_ref_change(state, head, user, &refname, ZERO_OID, &pr.head_oid).await;
crates/forge-web-repo/src/pages/pulls_list.rsmodified+1 -2
@@ -24,8 +24,7 @@ use crate::pages::repo_ctx::load_repo;
24 use crate::state::AppState;24 use crate::state::AppState;
25 use crate::views::parts::{RailItem, SubPart, rail};25 use crate::views::parts::{RailItem, SubPart, rail};
26 use crate::views::{26 use crate::views::{
27- avatar_url_unknown, iso_time, now_unix, relative_time, repo_href, shell, stamp_unix,27+ avatar_url_unknown, iso_time, now_unix, relative_time, repo_href, shell, stamp_unix, user_link,
28- user_link,
29 };28 };
30 29
31 path_param!(owner);30 path_param!(owner);
crates/forge-web/src/admin_cli.rsmodified+1 -4
@@ -255,10 +255,7 @@ pub async fn reset_password(config_path: &Path, username: &str) -> forge_core::R
255 }255 }
256 256
257 /// The store-level part of [`reset_password`]. Returns the new password and the display name.257 /// The store-level part of [`reset_password`]. Returns the new password and the display name.
258-async fn reset_password_in(258+async fn reset_password_in(store: &Store, username: &str) -> forge_core::Result<(String, String)> {
259- store: &Store,
260- username: &str,
261-) -> forge_core::Result<(String, String)> {
262 let user = store259 let user = store
263 .user_by_username(username)260 .user_by_username(username)
264 .await?261 .await?
crates/forge-web/src/importer_route_tests.rsmodified+2 -8
@@ -351,10 +351,7 @@ async fn full_api_import_brings_issues_pulls_comments_labels_and_releases() {
351 let job = store.import_job(&job.id).await.unwrap().unwrap();351 let job = store.import_job(&job.id).await.unwrap().unwrap();
352 assert_eq!(job.state, ImportState::Done, "{:?}", job.error);352 assert_eq!(job.state, ImportState::Done, "{:?}", job.error);
353 353
354- let (items, total) = store354+ let (items, total) = store.list_issues(&fx.repo.id, &all_issues()).await.unwrap();
355- .list_issues(&fx.repo.id, &all_issues())
356- .await
357- .unwrap();
358 assert_eq!(total, 2);355 assert_eq!(total, 2);
359 let issue = items.iter().find(|i| i.issue.title == "It breaks").unwrap();356 let issue = items.iter().find(|i| i.issue.title == "It breaks").unwrap();
360 assert_eq!(issue.issue.state, IssueState::Closed);357 assert_eq!(issue.issue.state, IssueState::Closed);
@@ -413,10 +410,7 @@ async fn full_api_import_brings_issues_pulls_comments_labels_and_releases() {
413 .await;410 .await;
414 let again = store.import_job(&again.id).await.unwrap().unwrap();411 let again = store.import_job(&again.id).await.unwrap().unwrap();
415 assert_eq!(again.state, ImportState::Done, "{:?}", again.error);412 assert_eq!(again.state, ImportState::Done, "{:?}", again.error);
416- let (items, total) = store413+ let (items, total) = store.list_issues(&fx.repo.id, &all_issues()).await.unwrap();
417- .list_issues(&fx.repo.id, &all_issues())
418- .await
419- .unwrap();
420 assert_eq!(total, 2);414 assert_eq!(total, 2);
421 let first = items.iter().find(|i| i.issue.title == "It breaks").unwrap();415 let first = items.iter().find(|i| i.issue.title == "It breaks").unwrap();
422 assert_eq!(store.list_comments(&first.issue.id).await.unwrap().len(), 1);416 assert_eq!(store.list_comments(&first.issue.id).await.unwrap().len(), 1);
crates/forge-web/src/page_route_tests/repo.rsmodified+6 -1
@@ -133,7 +133,12 @@ async fn demo_pages_render_from_the_repo_contents() {
133 body.contains("markdown-body") && body.contains("<table>"),133 body.contains("markdown-body") && body.contains("<table>"),
134 "GFM table rendered"134 "GFM table rendered"
135 );135 );
136- let (status, body) = get_as(&router, "/tahinli/demo/blob/main/docs/guide.md?plain=1", None).await;136+ let (status, body) = get_as(
137+ &router,
138+ "/tahinli/demo/blob/main/docs/guide.md?plain=1",
139+ None,
140+ )
141+ .await;
137 assert_eq!(status, 200);142 assert_eq!(status, 200);
138 assert!(body.contains("file-table"), "source shown as lines");143 assert!(body.contains("file-table"), "source shown as lines");
139 assert!(!body.contains("markdown-body"), "not rendered");144 assert!(!body.contains("markdown-body"), "not rendered");