diff --git a/crates/forge-core/src/store/contributions.rs b/crates/forge-core/src/store/contributions.rs index 28a253b..f805b01 100644 --- a/crates/forge-core/src/store/contributions.rs +++ b/crates/forge-core/src/store/contributions.rs @@ -430,7 +430,11 @@ mod tests { let since = "2026-03-01T00:00:00.000000000Z"; let until = "2026-03-02T00:00:00.000000000Z"; assert_eq!( - store.contribution_counts(&tahinli.id, since, "UTC").await.unwrap().len(), + store + .contribution_counts(&tahinli.id, since, "UTC") + .await + .unwrap() + .len(), 1 ); diff --git a/crates/forge-core/src/store/migrate.rs b/crates/forge-core/src/store/migrate.rs index a63b57c..d1ab77e 100644 --- a/crates/forge-core/src/store/migrate.rs +++ b/crates/forge-core/src/store/migrate.rs @@ -106,10 +106,16 @@ pub const MIGRATIONS: &[(u32, &str)] = &[ (64, include_str!("../../migrations/0064_merge_queue.sql")), (65, include_str!("../../migrations/0065_hue_colours.sql")), (66, include_str!("../../migrations/0066_session_ip.sql")), - (67, include_str!("../../migrations/0067_coauthored_commits.sql")), + ( + 67, + include_str!("../../migrations/0067_coauthored_commits.sql"), + ), (68, include_str!("../../migrations/0068_ci_jobs_runner.sql")), (69, include_str!("../../migrations/0069_user_prefs.sql")), - (70, include_str!("../../migrations/0070_pull_viewed_files.sql")), + ( + 70, + include_str!("../../migrations/0070_pull_viewed_files.sql"), + ), ]; /// The highest migration version this binary knows about. diff --git a/crates/forge-core/src/store/needs.rs b/crates/forge-core/src/store/needs.rs index a387e28..bf4afe2 100644 --- a/crates/forge-core/src/store/needs.rs +++ b/crates/forge-core/src/store/needs.rs @@ -272,8 +272,11 @@ impl Store { /// How many issues `assigned_issues` lists in all. pub async fn assigned_issues_total(&self, user_id: &str) -> Result { - self.count_rows(&assigned_issues_sql(&readable_repo()), viewer_params(user_id)) - .await + self.count_rows( + &assigned_issues_sql(&readable_repo()), + viewer_params(user_id), + ) + .await } /// The user's unread mentions, newest first, one page at a time. Mentions in repos the user @@ -347,7 +350,13 @@ mod tests { .set_repo_visibility(&repo.id, Visibility::Private) .await .unwrap(); - assert!(store.assigned_issues(&bob.id, 8, 0).await.unwrap().is_empty()); + assert!( + store + .assigned_issues(&bob.id, 8, 0) + .await + .unwrap() + .is_empty() + ); assert_eq!(store.assigned_issues_total(&bob.id).await.unwrap(), 0); } } diff --git a/crates/forge-core/src/store/pull_viewed.rs b/crates/forge-core/src/store/pull_viewed.rs index 6d8c90c..0ce3142 100644 --- a/crates/forge-core/src/store/pull_viewed.rs +++ b/crates/forge-core/src/store/pull_viewed.rs @@ -64,11 +64,7 @@ impl Store { let conn = self.inner.conn.lock().await; conn.execute( "DELETE FROM pull_viewed_files WHERE user_id = ?1 AND issue_id = ?2 AND path = ?3", - ( - user_id.to_string(), - issue_id.to_string(), - path.to_string(), - ), + (user_id.to_string(), issue_id.to_string(), path.to_string()), ) .await .map_err(db_err)?; diff --git a/crates/forge-core/src/store/user_prefs.rs b/crates/forge-core/src/store/user_prefs.rs index 659df0b..105f2eb 100644 --- a/crates/forge-core/src/store/user_prefs.rs +++ b/crates/forge-core/src/store/user_prefs.rs @@ -72,12 +72,21 @@ mod tests { async fn density_and_sound_round_trip_and_replace() { let dir = tempfile::tempdir().unwrap(); let store = Store::open(&dir.path().join("forge.db")).await.unwrap(); - let user = store.create_user("tahinli", None, "unused", false).await.unwrap(); + let user = store + .create_user("tahinli", None, "unused", false) + .await + .unwrap(); assert!(store.user_prefs(&user.id).await.unwrap().is_empty()); - store.set_user_pref(&user.id, DENSITY, "compact").await.unwrap(); + store + .set_user_pref(&user.id, DENSITY, "compact") + .await + .unwrap(); store.set_user_pref(&user.id, SOUND, "on").await.unwrap(); - store.set_user_pref(&user.id, DENSITY, "comfortable").await.unwrap(); + store + .set_user_pref(&user.id, DENSITY, "comfortable") + .await + .unwrap(); let prefs = store.user_prefs(&user.id).await.unwrap(); assert_eq!(prefs.get(DENSITY).map(String::as_str), Some("comfortable")); diff --git a/crates/forge-git/src/search.rs b/crates/forge-git/src/search.rs index 28f51ee..66c1fe7 100644 --- a/crates/forge-git/src/search.rs +++ b/crates/forge-git/src/search.rs @@ -343,15 +343,9 @@ mod tests { assert!(res.truncated, "max matches"); // No match is an empty result, not an error. - let res = grep( - &env, - &repo, - &oid, - "zzz-not-here", - GrepOptions::default(), - ) - .await - .unwrap(); + let res = grep(&env, &repo, &oid, "zzz-not-here", GrepOptions::default()) + .await + .unwrap(); assert!(res.hits.is_empty(), "no match"); assert!(!res.truncated, "no match"); } diff --git a/crates/forge-git/src/trailers.rs b/crates/forge-git/src/trailers.rs index 9a01795..7f70094 100644 --- a/crates/forge-git/src/trailers.rs +++ b/crates/forge-git/src/trailers.rs @@ -30,7 +30,12 @@ pub fn strip_co_authors(message: &str) -> String { let kept: Vec<&str> = lines[..start] .iter() .copied() - .chain(lines[start..].iter().copied().filter(|line| !is_trailer(line))) + .chain( + lines[start..] + .iter() + .copied() + .filter(|line| !is_trailer(line)), + ) .collect(); kept.join("\n").trim_end().to_owned() } diff --git a/crates/forge-runner/src/config.rs b/crates/forge-runner/src/config.rs index 9e80ba3..8f69fb2 100644 --- a/crates/forge-runner/src/config.rs +++ b/crates/forge-runner/src/config.rs @@ -700,7 +700,10 @@ mod tests { assert_eq!(bad.job_memory_limit(None), None); assert_eq!(bad.for_job(None).memory, "lots"); // Builtin: no `memory` means the whole budget; a declared one keeps its slack. - assert_eq!(limits.for_builtin_job(None, Some(6 * gib)).memory, (6 * gib).to_string()); + assert_eq!( + limits.for_builtin_job(None, Some(6 * gib)).memory, + (6 * gib).to_string() + ); assert_eq!( limits.for_builtin_job(Some(gib), Some(6 * gib)).memory, limits.for_job(Some(gib)).memory diff --git a/crates/forge-runner/src/executor.rs b/crates/forge-runner/src/executor.rs index ad44139..3a06ac3 100644 --- a/crates/forge-runner/src/executor.rs +++ b/crates/forge-runner/src/executor.rs @@ -15,9 +15,9 @@ use std::fs; use std::future::Future; use std::path::{Path, PathBuf}; use std::pin::Pin; +use std::process::{ExitStatus, Stdio}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::process::{ExitStatus, Stdio}; use std::time::Duration; use forge_ci::proto::{JobAssignment, Outcome}; @@ -135,7 +135,11 @@ pub fn job_env_with_defaults( let n = job_parallelism(limits); let mut pairs: Vec<(String, String)> = [ ("FORGE_CPUS", n.to_string()), - ("FORGE_MEMORY_BYTES", crate::sandbox::spec::parse_bytes(&limits.memory).map_or_else(|_| "0".to_owned(), |b| b.to_string())), + ( + "FORGE_MEMORY_BYTES", + crate::sandbox::spec::parse_bytes(&limits.memory) + .map_or_else(|_| "0".to_owned(), |b| b.to_string()), + ), ("CARGO_BUILD_JOBS", n.to_string()), ("MAKEFLAGS", format!("-j{n}")), ("CMAKE_BUILD_PARALLEL_LEVEL", n.to_string()), @@ -992,7 +996,13 @@ mod tests { fn sweep_removes_only_leftover_jobs_and_ulid_workspaces() { let dir = tempfile::tempdir().unwrap(); let work = dir.path(); - for d in ["jobs/job_01/overlay", "01JD6Z8Q4XW3N5R7T9V2B4C6E8/src", "oci", "notes", "check-7"] { + for d in [ + "jobs/job_01/overlay", + "01JD6Z8Q4XW3N5R7T9V2B4C6E8/src", + "oci", + "notes", + "check-7", + ] { fs::create_dir_all(work.join(d)).unwrap(); } fs::create_dir_all(work.join(".cache")).unwrap(); @@ -1053,7 +1063,15 @@ mod tests { .collect(); assert_eq!( names, - vec!["FORGE_CPUS", "FORGE_MEMORY_BYTES", "CARGO_BUILD_JOBS", "MAKEFLAGS", "CMAKE_BUILD_PARALLEL_LEVEL", "PLAIN", "MY_TOKEN"] + vec![ + "FORGE_CPUS", + "FORGE_MEMORY_BYTES", + "CARGO_BUILD_JOBS", + "MAKEFLAGS", + "CMAKE_BUILD_PARALLEL_LEVEL", + "PLAIN", + "MY_TOKEN" + ] ); } @@ -1096,12 +1114,19 @@ mod tests { #[test] fn parallelism_defaults_follow_the_cpu_limit_and_job_env_wins() { let mut job = fixture_job("true"); - let limits = Limits { cpus: "0.5".to_owned(), ..Limits::default() }; + let limits = Limits { + cpus: "0.5".to_owned(), + ..Limits::default() + }; let env = job_env_with_defaults(&job, &limits).expect("env"); assert!(env.contains(&("CARGO_BUILD_JOBS".to_owned(), "1".to_owned()))); - job.env.insert("CARGO_BUILD_JOBS".to_owned(), "7".to_owned()); + job.env + .insert("CARGO_BUILD_JOBS".to_owned(), "7".to_owned()); let env = job_env_with_defaults(&job, &limits).expect("env"); - let jobs: Vec<_> = env.iter().filter(|(k, _)| k == "CARGO_BUILD_JOBS").collect(); + let jobs: Vec<_> = env + .iter() + .filter(|(k, _)| k == "CARGO_BUILD_JOBS") + .collect(); assert_eq!(jobs, [&("CARGO_BUILD_JOBS".to_owned(), "7".to_owned())]); } diff --git a/crates/forge-runner/src/lib.rs b/crates/forge-runner/src/lib.rs index 80af47a..89788b3 100644 --- a/crates/forge-runner/src/lib.rs +++ b/crates/forge-runner/src/lib.rs @@ -14,8 +14,8 @@ pub mod disk; pub mod executor; pub mod limiter; pub mod logs; -pub mod metrics; pub mod memory; +pub mod metrics; pub mod oci; pub mod oom; pub mod pressure; diff --git a/crates/forge-runner/src/sandbox/helper.rs b/crates/forge-runner/src/sandbox/helper.rs index fe4b7c5..dffdcbc 100644 --- a/crates/forge-runner/src/sandbox/helper.rs +++ b/crates/forge-runner/src/sandbox/helper.rs @@ -248,8 +248,9 @@ fn prepare_dirs(layout: &Layout) -> Result<(), SandboxError> { fs::set_permissions(dir, fs::Permissions::from_mode(0o700)) .map_err(SandboxError::io(format!("cannot chmod {}", dir.display())))?; } - fs::set_permissions(&layout.tmp, fs::Permissions::from_mode(0o1777)) - .map_err(SandboxError::io(format!("cannot chmod {}", layout.tmp.display())))?; + fs::set_permissions(&layout.tmp, fs::Permissions::from_mode(0o1777)).map_err( + SandboxError::io(format!("cannot chmod {}", layout.tmp.display())), + )?; Ok(()) } diff --git a/crates/forge-runner/src/workspace.rs b/crates/forge-runner/src/workspace.rs index 4d32844..331285c 100644 --- a/crates/forge-runner/src/workspace.rs +++ b/crates/forge-runner/src/workspace.rs @@ -211,13 +211,21 @@ mod tests { fn clone_urls_are_checked_against_the_forge_scheme() { // (clone url, forge url, accepted) let cases: &[(&str, &str, bool)] = &[ - ("https://forge.example/o/r.git", "https://forge.example", true), + ( + "https://forge.example/o/r.git", + "https://forge.example", + true, + ), ("--upload-pack=sh", "https://forge.example", false), ("ext::sh -c id", "https://forge.example", false), ("https://a b/x", "https://forge.example", false), // Plain http is only accepted when the forge itself is http. ("http://forge.example/o/r.git", "http://forge.example", true), - ("http://forge.example/o/r.git", "https://forge.example", false), + ( + "http://forge.example/o/r.git", + "https://forge.example", + false, + ), ]; for (url, forge, ok) in cases { assert_eq!(validate_clone_url(url, forge).is_ok(), *ok, "case {url}"); diff --git a/crates/forge-runner/tests/integration/builtin.rs b/crates/forge-runner/tests/integration/builtin.rs index f418c06..dd19286 100644 --- a/crates/forge-runner/tests/integration/builtin.rs +++ b/crates/forge-runner/tests/integration/builtin.rs @@ -321,7 +321,10 @@ async fn sigkilled_helper_leaves_no_process_behind() { "job process {pid} survived the helper" ); } - assert!(!dir.path().join("jobs").join(job_id).exists(), "job dir was kept"); + assert!( + !dir.path().join("jobs").join(job_id).exists(), + "job dir was kept" + ); } #[tokio::test] @@ -344,9 +347,13 @@ async fn network_job_gets_its_own_network_without_private_ranges() { assert!(logs.contains("meta=blocked"), "{logs}"); assert!(!logs.contains("pasta is not installed"), "{logs}"); let pid_file = dir.path().join("jobs/job_01/pasta.pid"); - let leftover = fs::read_dir("/proc").expect("read /proc").flatten().any(|entry| { - fs::read(entry.path().join("cmdline")) - .is_ok_and(|cmd| String::from_utf8_lossy(&cmd).contains(&*pid_file.to_string_lossy())) - }); + let leftover = fs::read_dir("/proc") + .expect("read /proc") + .flatten() + .any(|entry| { + fs::read(entry.path().join("cmdline")).is_ok_and(|cmd| { + String::from_utf8_lossy(&cmd).contains(&*pid_file.to_string_lossy()) + }) + }); assert!(!leftover, "pasta outlived the job"); } diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 364adb1..d764045 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -352,12 +352,14 @@ else { window.scrollTo(0, 0); } } - // Continuity: the row a reader clicked grows into the title of the page it opens. The row takes the - // name forge-row once the response has arrived, just before the transition; the new page's main - // heading takes it in the transition's update callback, where the swap runs, after the old state - // is captured. Names are removed when the transition ends, since a duplicate name aborts a transition. - // Without the API or with reduced motion the swap runs as it always has. Only a link from a row - // comes here: live refreshes, back and forward and form posts never animate. + // Continuity: every navigation (a link, back or forward) is one calm View Transition. The top bar and + // the repo head stay still, the active tab slides to its new place, and the page body fades in. A link + // from a row also grows into the title of the page it opens: the row takes the name forge-row once the + // response has arrived, the new page's title takes it in the transition's update callback, where the + // swap runs. Names are on only for the transition: `html.is-navigating` in _continuity.scss, and the + // row's and title's own names are removed when it ends, since a duplicate name aborts a transition. + // Without the API or with reduced motion the swap runs as it always has. Live refreshes and form + // posts never animate. var MORPH_NAME = 'forge-row'; // The title a row grows into, by page: commit, issue and pull, CI run and job, a repo's title row, @@ -375,8 +377,10 @@ } function morph(row, run) { - if (!row || !document.startViewTransition || motionHeld()) { run(); return undefined; } - row.style.viewTransitionName = MORPH_NAME; + if (!document.startViewTransition || motionHeld()) { run(); return undefined; } + var root = document.documentElement; + root.classList.add('is-navigating'); + if (row) { row.style.viewTransitionName = MORPH_NAME; } return new Promise(function (resolve, reject) { var ran = false; var title = null; @@ -384,9 +388,9 @@ if (ran) { return; } ran = true; // The old row leaves the page now, so its name goes with it. - row.style.viewTransitionName = ''; + if (row) { row.style.viewTransitionName = ''; } try { run(); } catch (err) { reject(err); return; } - title = pageTitle(); + title = row ? pageTitle() : null; if (title) { title.style.viewTransitionName = MORPH_NAME; } resolve(); } @@ -400,10 +404,12 @@ // A skipped transition may never call its callback: the swap then runs here instead. transition.ready.catch(function () { }); transition.updateCallbackDone.then(update, update); - transition.finished.then(function () { - row.style.viewTransitionName = ''; + var done = function () { + root.classList.remove('is-navigating'); + if (row) { row.style.viewTransitionName = ''; } if (title) { title.style.viewTransitionName = ''; } - }, function () { }); + }; + transition.finished.then(done, done); }); } @@ -560,8 +566,8 @@ // Other parts of this file follow page changes through this event (list memory, say). document.dispatchEvent(new CustomEvent('forge:swapped', { detail: { how: how, url: dest } })); }; - // A link from a row swaps inside its transition, and the load counts as done only after it. - if (how === 'nav' && o.morph) { return morph(o.morph, finish); } + // A navigation swaps inside its transition, and the load counts as done only after it. + if (how === 'nav' || how === 'pop') { return morph(o.morph, finish); } finish(); }).catch(function () { if (mark !== latest || o.how === 'live') { return; } @@ -1594,7 +1600,7 @@ } saveScroll(); // The row the link sits in, if any: the page it opens grows out of that row (see morph). - var row = a.closest('[data-kb-row]'); + var row = a.closest('nav, .repo-tabs, .pathbar, .topbar') ? null : a.closest('[data-kb-row], tbody tr, ul > li'); load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'nav', keep: false, post: false, form: null, morph: row }); }, true); diff --git a/crates/forge-web/src/advisories/worker.rs b/crates/forge-web/src/advisories/worker.rs index a137a5f..47f6da9 100644 --- a/crates/forge-web/src/advisories/worker.rs +++ b/crates/forge-web/src/advisories/worker.rs @@ -217,12 +217,14 @@ async fn import(state: &AppState, ecosystem: &str, path: &Path) -> Result<()> { let owned_path = path.to_owned(); let eco = ecosystem.to_owned(); let parser = tokio::task::spawn_blocking(move || -> usize { - let parsed = File::open(&owned_path).map_err(Error::from).and_then(|file| { - read_dump(BufReader::new(file), &eco, |batch| { - tx.blocking_send(Ok(Some(batch))) - .map_err(|_| Error::Invalid("advisory import was stopped".into())) - }) - }); + let parsed = File::open(&owned_path) + .map_err(Error::from) + .and_then(|file| { + read_dump(BufReader::new(file), &eco, |batch| { + tx.blocking_send(Ok(Some(batch))) + .map_err(|_| Error::Invalid("advisory import was stopped".into())) + }) + }); // The store commits only on `Ok(None)`, so a panic above (sender dropped) rolls back. match parsed { Ok(skipped) => { diff --git a/crates/forge-web/src/api/releases.rs b/crates/forge-web/src/api/releases.rs index 703fc3a..de69e36 100644 --- a/crates/forge-web/src/api/releases.rs +++ b/crates/forge-web/src/api/releases.rs @@ -656,7 +656,12 @@ mod tests { 401, false, ), - ("token without repo scope", Some(scopeless.as_str()), 403, false), + ( + "token without repo scope", + Some(scopeless.as_str()), + 403, + false, + ), ]; for (name, auth, want, error_body) in cases { let (status, body) = post_json(&f, auth, r#"{"tag":"v1"}"#).await; diff --git a/crates/forge-web/src/api/statuses.rs b/crates/forge-web/src/api/statuses.rs index 327aa79..1d36d5e 100644 --- a/crates/forge-web/src/api/statuses.rs +++ b/crates/forge-web/src/api/statuses.rs @@ -344,13 +344,12 @@ mod tests { #[tokio::test] async fn refused_writes_return_their_status() { let s = setup(Visibility::Public).await; - let owner = s - .fx - .store - .user_by_username(OWNER) - .await - .unwrap() - .expect("owner"); + let owner = + s.fx.store + .user_by_username(OWNER) + .await + .unwrap() + .expect("owner"); let session = generate_token(); crate::test_support::create_session(&s.fx.store, &owner.id, &session, "csrf-value").await; let cookie = format!("__Host-{SESSION_COOKIE}={session}"); @@ -361,18 +360,106 @@ mod tests { let bad_sha = report_uri("abc123"); let missing = report_uri(&"0".repeat(40)); // (case, uri, auth, cookie, body, expected status, expects a JSON error body) - type Case<'a> = (&'a str, &'a str, Option<&'a str>, Option<&'a str>, Option<&'a str>, u16, bool); + type Case<'a> = ( + &'a str, + &'a str, + Option<&'a str>, + Option<&'a str>, + Option<&'a str>, + u16, + bool, + ); let cases: [Case<'_>; 10] = [ - ("read-only token", report.as_str(), Some(reader.as_str()), None, Some(SUCCESS), 403, true), - ("anonymous", report.as_str(), None, None, Some(SUCCESS), 401, true), - ("bad token", report.as_str(), Some("Bearer forge_not_a_real_token"), None, Some(SUCCESS), 401, false), - ("session cookie alone", report.as_str(), None, Some(cookie.as_str()), Some(SUCCESS), 401, false), - ("token without repo scope", report.as_str(), Some(unscoped.as_str()), None, Some(SUCCESS), 403, false), - ("sha too short", bad_sha.as_str(), Some(writer.as_str()), None, Some(SUCCESS), 422, false), - ("unknown state", report.as_str(), Some(writer.as_str()), None, Some(r#"{"state":"maybe"}"#), 422, false), - ("malformed json", report.as_str(), Some(writer.as_str()), None, Some("{not json"), 400, false), - ("javascript target url", report.as_str(), Some(writer.as_str()), None, Some(r#"{"state":"success","target_url":"javascript:alert(1)"}"#), 422, false), - ("unknown commit", missing.as_str(), Some(writer.as_str()), None, Some(SUCCESS), 404, false), + ( + "read-only token", + report.as_str(), + Some(reader.as_str()), + None, + Some(SUCCESS), + 403, + true, + ), + ( + "anonymous", + report.as_str(), + None, + None, + Some(SUCCESS), + 401, + true, + ), + ( + "bad token", + report.as_str(), + Some("Bearer forge_not_a_real_token"), + None, + Some(SUCCESS), + 401, + false, + ), + ( + "session cookie alone", + report.as_str(), + None, + Some(cookie.as_str()), + Some(SUCCESS), + 401, + false, + ), + ( + "token without repo scope", + report.as_str(), + Some(unscoped.as_str()), + None, + Some(SUCCESS), + 403, + false, + ), + ( + "sha too short", + bad_sha.as_str(), + Some(writer.as_str()), + None, + Some(SUCCESS), + 422, + false, + ), + ( + "unknown state", + report.as_str(), + Some(writer.as_str()), + None, + Some(r#"{"state":"maybe"}"#), + 422, + false, + ), + ( + "malformed json", + report.as_str(), + Some(writer.as_str()), + None, + Some("{not json"), + 400, + false, + ), + ( + "javascript target url", + report.as_str(), + Some(writer.as_str()), + None, + Some(r#"{"state":"success","target_url":"javascript:alert(1)"}"#), + 422, + false, + ), + ( + "unknown commit", + missing.as_str(), + Some(writer.as_str()), + None, + Some(SUCCESS), + 404, + false, + ), ]; for (name, uri, auth, cookie, body, want, error_body) in cases { let (status, json) = send(&s.fx.router, "POST", uri, auth, cookie, body).await; diff --git a/crates/forge-web/src/auth.rs b/crates/forge-web/src/auth.rs index be91f45..dd4e618 100644 --- a/crates/forge-web/src/auth.rs +++ b/crates/forge-web/src/auth.rs @@ -11,10 +11,10 @@ use forge_core::session::{new_csrf_token, new_session_token}; use forge_core::time::stamp_after; use forge_core::token::{constant_time_eq, hash_token}; use forge_core::{Session, Store, User, secret, totp}; +use tokio::sync::Semaphore; use topcoat::Result; use topcoat::context::{Cx, app_context}; use topcoat::cookie::{Cookie, Cookies, SameSite, cookies, time}; -use tokio::sync::Semaphore; use topcoat::router::error::{forbidden, see_other}; use topcoat::router::request::{headers, uri}; diff --git a/crates/forge-web/src/backup/tests.rs b/crates/forge-web/src/backup/tests.rs index 918d572..a18f29c 100644 --- a/crates/forge-web/src/backup/tests.rs +++ b/crates/forge-web/src/backup/tests.rs @@ -417,7 +417,10 @@ async fn failed_backups_leave_no_partial_directory() { .expect("out") .map(|e| e.expect("entry").file_name().to_string_lossy().into_owned()) .collect(); - assert!(left.is_empty(), "case broken repo, nothing may be left behind: {left:?}"); + assert!( + left.is_empty(), + "case broken repo, nothing may be left behind: {left:?}" + ); } #[tokio::test] diff --git a/crates/forge-web/src/ci/api.rs b/crates/forge-web/src/ci/api.rs index 6c6777c..069d5a6 100644 --- a/crates/forge-web/src/ci/api.rs +++ b/crates/forge-web/src/ci/api.rs @@ -254,7 +254,9 @@ fn target_labels(target: Option<&str>) -> Vec { let plain = |part: &str| { !part.is_empty() && part.len() <= 32 - && part.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_') + && part + .bytes() + .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_') }; match target.split_once('-') { Some((arch, os)) if plain(arch) && plain(os) => { @@ -781,7 +783,11 @@ async fn heartbeat(cx: &Cx) -> topcoat::Result { // A busy runner only heartbeats here. Its state is read only when it is not // recorded online, so a steady heartbeat costs a map lookup. if !state.ci_live.runner_recorded_online(runner_id) { - let disabled = state.store.runner_disabled(runner_id).await.unwrap_or(false); + let disabled = state + .store + .runner_disabled(runner_id) + .await + .unwrap_or(false); state.ci_live.note_runner_online(runner_id, !disabled); } let said = headers(cx) diff --git a/crates/forge-web/src/ci/mod.rs b/crates/forge-web/src/ci/mod.rs index a0c5c96..f1bfae4 100644 --- a/crates/forge-web/src/ci/mod.rs +++ b/crates/forge-web/src/ci/mod.rs @@ -12,9 +12,9 @@ use crate::state::AppState; pub mod api; pub mod live; +pub mod metrics_chart; pub mod reaper; pub mod release; -pub mod metrics_chart; pub mod runner_log; pub mod runner_metrics; pub mod schedule; diff --git a/crates/forge-web/src/ci/release.rs b/crates/forge-web/src/ci/release.rs index 1d77efc..4f8dfe4 100644 --- a/crates/forge-web/src/ci/release.rs +++ b/crates/forge-web/src/ci/release.rs @@ -370,7 +370,10 @@ fn grouped_bullets(commits: &[CommitInfo], footer_len: usize) -> String { .iter() .flat_map(|group| { let section = section_of(&group.kind); - group.clauses.iter().map(move |clause| (section, clause.clone())) + group + .clauses + .iter() + .map(move |clause| (section, clause.clone())) }) .collect(), None => vec![(section_of(""), commit.summary.clone())], @@ -645,7 +648,11 @@ title = "forge {tag}" let release = release_named(&fx, "v1.1").await.expect("release made"); let short = &oid[..7]; assert!(release.body.starts_with("### Features\n- one (")); - assert!(release.body.contains(&format!("### Fixes\n- two ({short})"))); + assert!( + release + .body + .contains(&format!("### Fixes\n- two ({short})")) + ); assert!(release.body.ends_with("Full changelog: v1.0...v1.1")); assert!( !release.body.contains("- change ("), diff --git a/crates/forge-web/src/ci/schedule.rs b/crates/forge-web/src/ci/schedule.rs index c55d878..6a79a1d 100644 --- a/crates/forge-web/src/ci/schedule.rs +++ b/crates/forge-web/src/ci/schedule.rs @@ -1185,7 +1185,8 @@ run = "make" ( "kept", on( - &CONFIG_SUPERSEDE.replace("cancel_superseded = true", "cancel_superseded = false"), + &CONFIG_SUPERSEDE + .replace("cancel_superseded = true", "cancel_superseded = false"), "kept", ), false, @@ -1217,7 +1218,11 @@ run = "make" assert_eq!(second.state, RunState::Queued, "{case}: the newest run"); if cancelled { let jobs = store.jobs_for_run(&first.id).await.unwrap(); - assert_eq!(state_of(&jobs, "build"), Some(JobState::Cancelled), "{case}"); + assert_eq!( + state_of(&jobs, "build"), + Some(JobState::Cancelled), + "{case}" + ); } } } diff --git a/crates/forge-web/src/exporter.rs b/crates/forge-web/src/exporter.rs index 58880eb..1eaf76b 100644 --- a/crates/forge-web/src/exporter.rs +++ b/crates/forge-web/src/exporter.rs @@ -279,9 +279,8 @@ async fn stage_repo(state: &AppState, repo: &Repo, dir: &Path) -> Result<(), Str write_json(&dir.join("repo.json"), &meta).await?; // Issues go to the file as they are built, so a repo's issues are never all in memory at once. - let mut out = BufWriter::new( - std::fs::File::create(dir.join("issues.json")).map_err(|e| e.to_string())?, - ); + let mut out = + BufWriter::new(std::fs::File::create(dir.join("issues.json")).map_err(|e| e.to_string())?); let mut written = 0usize; let mut page = 1; loop { @@ -316,7 +315,11 @@ async fn stage_repo(state: &AppState, repo: &Repo, dir: &Path) -> Result<(), Str .map_err(|e| e.to_string())?; let names: HashMap = names.into_iter().map(|(k, (name, _))| (k, name)).collect(); - write_array_item(&mut out, &mut written, &issue_json(&item, &comments, &names))?; + write_array_item( + &mut out, + &mut written, + &issue_json(&item, &comments, &names), + )?; } if got == 0 || (u64::from(page) * u64::from(PAGE)) >= total { break; diff --git a/crates/forge-web/src/i18n/integrations.rs b/crates/forge-web/src/i18n/integrations.rs index 8e8d3af..6f188f5 100644 --- a/crates/forge-web/src/i18n/integrations.rs +++ b/crates/forge-web/src/i18n/integrations.rs @@ -339,12 +339,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (HookArchivedNotice, Tr) => { "Bu depo arşivlenmiş. Web kancaları salt okunurdur: değiştirilemez, test edilemez ya da yeniden teslim edilemez." } - (HookNoticeConfirm, En) => { - "The delete was not confirmed. Nothing was deleted." - } - (HookNoticeConfirm, Tr) => { - "Silme onaylanmadı. Hiçbir şey silinmedi." - } + (HookNoticeConfirm, En) => "The delete was not confirmed. Nothing was deleted.", + (HookNoticeConfirm, Tr) => "Silme onaylanmadı. Hiçbir şey silinmedi.", (HookNoticeCreated, En) => "Webhook created. A ping was queued.", (HookNoticeCreated, Tr) => "Web kancası oluşturuldu. Bir ping sıraya alındı.", (HookNoticeDeleted, En) => "Webhook deleted.", @@ -374,17 +370,15 @@ pub fn t(lang: Lang, key: K) -> &'static str { (NoMirrors, En) => "No mirrors yet.", (NoMirrors, Tr) => "Henüz yansı yok.", (NoWebhooks, En) => "No webhooks yet. Add one to send events to another service.", - (NoWebhooks, Tr) => "Henüz web kancası yok. Olayları başka bir servise göndermek için bir tane ekleyin.", + (NoWebhooks, Tr) => { + "Henüz web kancası yok. Olayları başka bir servise göndermek için bir tane ekleyin." + } (NoneYet, En) => "none yet", (NoneYet, Tr) => "henüz yok", (NoResponse, En) => "no response", (NoResponse, Tr) => "yanıt yok", - (NoticeConfirm, En) => { - "The delete was not confirmed. Nothing was deleted." - } - (NoticeConfirm, Tr) => { - "Silme onaylanmadı. Hiçbir şey silinmedi." - } + (NoticeConfirm, En) => "The delete was not confirmed. Nothing was deleted.", + (NoticeConfirm, Tr) => "Silme onaylanmadı. Hiçbir şey silinmedi.", (NoticeCreated, En) => { "Push mirror created. It will be pushed after the next push or on its interval." } diff --git a/crates/forge-web/src/i18n/link.rs b/crates/forge-web/src/i18n/link.rs index c3d6b1d..7ecc996 100644 --- a/crates/forge-web/src/i18n/link.rs +++ b/crates/forge-web/src/i18n/link.rs @@ -51,7 +51,16 @@ mod tests { #[test] fn every_string_has_no_em_dash() { for lang in [Lang::En, Lang::Tr] { - for key in [K::Restarting, K::BackSubmit, K::Saved, K::Done, K::DraftRestored, K::DraftDiscard, K::SelectFilter, K::SelectNone] { + for key in [ + K::Restarting, + K::BackSubmit, + K::Saved, + K::Done, + K::DraftRestored, + K::DraftDiscard, + K::SelectFilter, + K::SelectNone, + ] { assert!(!t(lang, key).contains('\u{2014}')); } } diff --git a/crates/forge-web/src/i18n/migrate.rs b/crates/forge-web/src/i18n/migrate.rs index aa6a192..c22b407 100644 --- a/crates/forge-web/src/i18n/migrate.rs +++ b/crates/forge-web/src/i18n/migrate.rs @@ -286,7 +286,10 @@ fn pair(key: K) -> (&'static str, &'static str) { K::JobProgress => ("Progress", "İlerleme"), K::JobNoLog => ("Nothing yet.", "Henüz bir şey yok."), K::JobStarted => ("Started", "Başladı"), - K::RetryFailedTitle => ("Retry failed imports", "Başarısız içe aktarmaları yeniden dene"), + K::RetryFailedTitle => ( + "Retry failed imports", + "Başarısız içe aktarmaları yeniden dene", + ), K::RetrySelected => ("Retry selected", "Seçilenleri yeniden dene"), K::RetryNone => ("No failed imports", "Başarısız içe aktarma yok"), K::RetryTokenHelp => ( @@ -369,7 +372,9 @@ pub fn export_ttl_note(lang: Lang, days: u64) -> String { pub fn bulk_skipped(lang: Lang, list: &str) -> String { match lang { Lang::En => format!("Not imported: {list}. Import them one by one to choose another name."), - Lang::Tr => format!("İçe aktarılmayanlar: {list}. Başka bir ad seçmek için onları tek tek içe aktarın."), + Lang::Tr => format!( + "İçe aktarılmayanlar: {list}. Başka bir ad seçmek için onları tek tek içe aktarın." + ), } } diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs index 9f53b0d..2651174 100644 --- a/crates/forge-web/src/i18n/misc.rs +++ b/crates/forge-web/src/i18n/misc.rs @@ -666,7 +666,9 @@ pub fn t(lang: Lang, key: K) -> &'static str { (InvalidRepoName, Tr) => "geçersiz depo adı", (ReadmeLabel, En) => "Add a README", (ReadmeLabel, Tr) => "README ekle", - (ReadmeHelp, En) => "A README.md with the name and description, so the repository is not empty.", + (ReadmeHelp, En) => { + "A README.md with the name and description, so the repository is not empty." + } (ReadmeHelp, Tr) => "Adı ve açıklamasıyla bir README.md; depo boş başlamaz.", (LicenseLabel, En) => "License", (LicenseLabel, Tr) => "Lisans", @@ -676,8 +678,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { (LicenseHelp, Tr) => "Tam metniyle bir LICENSE dosyası ekler.", (UnknownLicense, En) => "unknown license", (UnknownLicense, Tr) => "Bilinmeyen lisans.", - (MirrorWithFiles, En) => "A mirror fills the repository from its source; leave README and license off.", - (MirrorWithFiles, Tr) => "Yansı, depoyu kaynağından doldurur; README ve lisansı kapalı bırakın.", + (MirrorWithFiles, En) => { + "A mirror fills the repository from its source; leave README and license off." + } + (MirrorWithFiles, Tr) => { + "Yansı, depoyu kaynağından doldurur; README ve lisansı kapalı bırakın." + } (ContributionsTitle, En) => "Contributions", (ContributionsTitle, Tr) => "Katkılar", (ContributionsLastYear, En) => "contributions in the last year", diff --git a/crates/forge-web/src/i18n/pulls.rs b/crates/forge-web/src/i18n/pulls.rs index 1364cfd..711ea68 100644 --- a/crates/forge-web/src/i18n/pulls.rs +++ b/crates/forge-web/src/i18n/pulls.rs @@ -116,8 +116,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { (FiltersApplied, Tr) => "Filtreler uygulandı · ", (ClearFilters, En) => "Clear filters", (ClearFilters, Tr) => "Filtreleri temizle", - (NoPullRequestsYet, En) => "No pull requests yet. Push a branch, then open one to propose its changes.", - (NoPullRequestsYet, Tr) => "Henüz çekme isteği yok. Bir dal gönderin, ardından değişikliklerini önermek için bir çekme isteği açın.", + (NoPullRequestsYet, En) => { + "No pull requests yet. Push a branch, then open one to propose its changes." + } + (NoPullRequestsYet, Tr) => { + "Henüz çekme isteği yok. Bir dal gönderin, ardından değişikliklerini önermek için bir çekme isteği açın." + } (NoPullRequestsMatch, En) => "No pull requests match these filters.", (NoPullRequestsMatch, Tr) => "Bu filtrelere uyan çekme isteği yok.", (SortNewest, En) => "Newest", diff --git a/crates/forge-web/src/i18n/repo_admin.rs b/crates/forge-web/src/i18n/repo_admin.rs index 0db144b..8f3e982 100644 --- a/crates/forge-web/src/i18n/repo_admin.rs +++ b/crates/forge-web/src/i18n/repo_admin.rs @@ -499,12 +499,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { (TypeToConfirmBefore, Tr) => "Onaylamak için ", (UnarchiveRepo, En) => "Unarchive repository", (UnarchiveRepo, Tr) => "Depoyu arşivden çıkar", - (UnderstandNeeded, En) => { - "The change was not confirmed. Nothing was changed." - } - (UnderstandNeeded, Tr) => { - "Değişiklik onaylanmadı. Hiçbir şey değiştirilmedi." - } + (UnderstandNeeded, En) => "The change was not confirmed. Nothing was changed.", + (UnderstandNeeded, Tr) => "Değişiklik onaylanmadı. Hiçbir şey değiştirilmedi.", (UnknownUser, En) => "No user has that username.", (UnknownUser, Tr) => "Bu kullanıcı adına sahip bir kullanıcı yok.", (Username, En) => "Username", diff --git a/crates/forge-web/src/importer/tests.rs b/crates/forge-web/src/importer/tests.rs index 0cf43db..1fb5afb 100644 --- a/crates/forge-web/src/importer/tests.rs +++ b/crates/forge-web/src/importer/tests.rs @@ -313,7 +313,13 @@ async fn git_url_import_copies_all_branches_and_tags_into_a_normal_repo() { &Transport::Local("/nonexistent/path.git".into()), ) .await; - let bad_job = fx.state.store.import_job(&bad_job.id).await.unwrap().unwrap(); + let bad_job = fx + .state + .store + .import_job(&bad_job.id) + .await + .unwrap() + .unwrap(); assert_eq!(bad_job.state, ImportState::Failed); assert!(bad_job.error.is_some()); } @@ -513,7 +519,13 @@ async fn retry_submit_leaves_another_users_failed_job_alone() { .set_import_state(&job.id, ImportState::Failed, Some("rate limit")) .await .unwrap(); - create_session(&fx.state.store, &other.id, "retry-other-session", "retry-csrf").await; + create_session( + &fx.state.store, + &other.id, + "retry-other-session", + "retry-csrf", + ) + .await; let router = app_router(fx.state.clone()); let cookie = format!("__Host-{SESSION_COOKIE}=retry-other-session"); diff --git a/crates/forge-web/src/internal.rs b/crates/forge-web/src/internal.rs index 8523a2b..22dc86c 100644 --- a/crates/forge-web/src/internal.rs +++ b/crates/forge-web/src/internal.rs @@ -253,7 +253,10 @@ async fn admin_live_endpoint(cx: &Cx, body: Body) -> topcoat::Result { for id in &req.account_ids { state.live.bump(&Topic::Account(id.clone())); } - Ok(admin_response(StatusCode::OK, serde_json::json!({ "ok": true }))) + Ok(admin_response( + StatusCode::OK, + serde_json::json!({ "ok": true }), + )) } /// `POST /internal/admin/lfs-gc`. The body is ignored. diff --git a/crates/forge-web/src/live.rs b/crates/forge-web/src/live.rs index 0c42ee7..e61dfe8 100644 --- a/crates/forge-web/src/live.rs +++ b/crates/forge-web/src/live.rs @@ -293,25 +293,28 @@ where topics.iter().map(|topic| hub.subscribe(topic)).collect(); wakes.extend(extra); let last = read().await?; - Ok(stream::unfold(Follow { wakes, read, last }, move |mut follow| async move { - loop { - if !wait_any(&mut follow.wakes).await { - return None; - } - let now = match (follow.read)().await { - Ok(now) => now, - Err(e) => { - tracing::error!(error = %e, "live: could not read the page state"); + Ok(stream::unfold( + Follow { wakes, read, last }, + move |mut follow| async move { + loop { + if !wait_any(&mut follow.wakes).await { return None; } - }; - if now == follow.last { - continue; + let now = match (follow.read)().await { + Ok(now) => now, + Err(e) => { + tracing::error!(error = %e, "live: could not read the page state"); + return None; + } + }; + if now == follow.last { + continue; + } + follow.last = now; + return Some((named_event(name), follow)); } - follow.last = now; - return Some((named_event(name), follow)); - } - })) + }, + )) } #[cfg(test)] diff --git a/crates/forge-web/src/mail/templates.rs b/crates/forge-web/src/mail/templates.rs index 67bfad3..374d5cd 100644 --- a/crates/forge-web/src/mail/templates.rs +++ b/crates/forge-web/src/mail/templates.rs @@ -217,7 +217,11 @@ mod tests { fn subject_names_the_repo_title_and_number_and_stays_on_one_line() { // A plain title is named as-is; a newline in the title cannot split the subject. let cases = [ - ("plain", "Crash on start", "[bob/widgets] Crash on start (#7)"), + ( + "plain", + "Crash on start", + "[bob/widgets] Crash on start (#7)", + ), ("newline", "two\r\nlines", "[bob/widgets] two lines (#7)"), ]; for (name, title, want) in cases { diff --git a/crates/forge-web/src/main.rs b/crates/forge-web/src/main.rs index 9eb8a58..5df6f34 100644 --- a/crates/forge-web/src/main.rs +++ b/crates/forge-web/src/main.rs @@ -49,8 +49,8 @@ mod pulls_sync; mod raw; mod release_ops; mod render; -mod repo_stats; mod replication; +mod repo_stats; mod self_update; mod signatures; mod ssh_backend; @@ -145,7 +145,10 @@ fn reexec_with_allocator_env(raw: &[std::ffi::OsString]) { }; use std::os::unix::process::CommandExt; // exec only returns on failure; the server then runs on without the variable. - let e = std::process::Command::new(exe).args(raw).env(VAR, "0").exec(); + let e = std::process::Command::new(exe) + .args(raw) + .env(VAR, "0") + .exec(); eprintln!("forge: cannot re-run with {VAR}=0: {e}"); } diff --git a/crates/forge-web/src/pages/activity.rs b/crates/forge-web/src/pages/activity.rs index 980c189..f58a8b4 100644 --- a/crates/forge-web/src/pages/activity.rs +++ b/crates/forge-web/src/pages/activity.rs @@ -15,10 +15,10 @@ use topcoat::router::{Body, HeaderValue, StatusCode, route}; use crate::auth::current_user; use crate::pages::ci_runs::{changed_stream, events_response, run_href}; -use futures_util::Stream; -use topcoat::router::content::sse::Event; use crate::state::AppState; use crate::views::repo_href; +use futures_util::Stream; +use topcoat::router::content::sse::Event; /// How far back a finished run still counts as recent in the activity JSON, in seconds. const RECENT_SECS: i64 = 120; diff --git a/crates/forge-web/src/pages/admin_backups.rs b/crates/forge-web/src/pages/admin_backups.rs index 54e1aea..14794ef 100644 --- a/crates/forge-web/src/pages/admin_backups.rs +++ b/crates/forge-web/src/pages/admin_backups.rs @@ -141,8 +141,8 @@ async fn backups_view(

(g::t(lang, K::Backups))

-

(g::t(lang, K::BackupsIntro))

+

(g::t(lang, K::BackupsIntro))

if let Some(message) = notice {

(message.as_str())

diff --git a/crates/forge-web/src/pages/admin_health.rs b/crates/forge-web/src/pages/admin_health.rs index 4ddb187..1940bfd 100644 --- a/crates/forge-web/src/pages/admin_health.rs +++ b/crates/forge-web/src/pages/admin_health.rs @@ -446,12 +446,10 @@ async fn alert_rows(state: &AppState, lang: Lang) -> Result> { .active_alerts() .await? .into_iter() - .map(|alert| { - AlertRow { - title: alert_text::title(lang, &alert.kind, &alert.subject, false), - body: alert_text::body(lang, &alert.kind, &alert.subject, &alert.detail, false), - stamp: alert.raised_at.clone(), - } + .map(|alert| AlertRow { + title: alert_text::title(lang, &alert.kind, &alert.subject, false), + body: alert_text::body(lang, &alert.kind, &alert.subject, &alert.detail, false), + stamp: alert.raised_at.clone(), }) .collect()) } @@ -498,12 +496,12 @@ async fn health_view(

(at(lang, A::Health))

-

- - (summary) -

-

(at(lang, A::HealthIntro))

+

+ + (summary) +

+

(at(lang, A::HealthIntro))

if count > 0 { ) }) } @@ -404,7 +406,9 @@ mod tests { let fx = fixture(Visibility::Public).await; let reply = send(&fx.router, "GET", &base(), true, None, &[]).await; assert_eq!(reply.status, 200); - assert!(reply.text().contains("No pull requests yet. Push a branch, then open one to propose its changes.")); + assert!(reply.text().contains( + "No pull requests yet. Push a branch, then open one to propose its changes." + )); assert_eq!(rows(&reply.text()), 0); } diff --git a/crates/forge-web/src/pages/push.rs b/crates/forge-web/src/pages/push.rs index 684c700..a909057 100644 --- a/crates/forge-web/src/pages/push.rs +++ b/crates/forge-web/src/pages/push.rs @@ -94,10 +94,7 @@ fn check_endpoint(endpoint: &str, policy: &WebhookPolicy) -> forge_core::Result< /// The browser's P-256 public key must be an uncompressed point, and its auth secret 16 bytes. fn check_keys(p256dh: &str, auth: &str) -> forge_core::Result<()> { let point = crypto::decode_b64(p256dh)?; - if point.len() != 65 - || point[0] != 0x04 - || p256::PublicKey::from_sec1_bytes(&point).is_err() - { + if point.len() != 65 || point[0] != 0x04 || p256::PublicKey::from_sec1_bytes(&point).is_err() { return Err(forge_core::Error::Invalid( "the browser key is not a P-256 public key".into(), )); @@ -298,9 +295,9 @@ async fn apple_touch_icon() -> Result<(StatusCode, HeaderMap, &'static [u8])> { #[cfg(test)] mod tests { use forge_core::Store; + use p256::elliptic_curve::sec1::ToSec1Point; use topcoat::router::request::Request; use topcoat::router::{Body, Router, to_bytes}; - use p256::elliptic_curve::sec1::ToSec1Point; use crate::auth::SESSION_COOKIE; use crate::test_support::{app_router, create_session, test_state}; @@ -339,8 +336,7 @@ mod tests { /// A browser key and auth secret as a browser would send them: base64url, uncompressed point. fn browser_keys() -> (String, String) { - let secret = p256::SecretKey::from_slice(&crypto::new_vapid_private()) - .expect("scalar"); + let secret = p256::SecretKey::from_slice(&crypto::new_vapid_private()).expect("scalar"); let point = secret.public_key().to_sec1_point(false); ( crypto::encode_b64(point.as_bytes()), diff --git a/crates/forge-web/src/pages/reactions_tests.rs b/crates/forge-web/src/pages/reactions_tests.rs index 05d658d..05fc71f 100644 --- a/crates/forge-web/src/pages/reactions_tests.rs +++ b/crates/forge-web/src/pages/reactions_tests.rs @@ -295,7 +295,10 @@ async fn refused_reactions_are_rejected_and_change_nothing() { ) .await; assert_eq!(wrong_comment.status, 404, "comment of another issue"); - assert!(on_issue(&s).await.is_empty(), "wrong target: nothing changes"); + assert!( + on_issue(&s).await.is_empty(), + "wrong target: nothing changes" + ); // Case: an unknown reaction and an unknown target kind are 400. let bad_reaction = post( diff --git a/crates/forge-web/src/pages/refs.rs b/crates/forge-web/src/pages/refs.rs index 560a26f..06e667a 100644 --- a/crates/forge-web/src/pages/refs.rs +++ b/crates/forge-web/src/pages/refs.rs @@ -122,7 +122,7 @@ async fn refs_table(rows: Vec, kind_label: &str, lang: Lang) -> Result for row in rows.into_iter() { - + (row.name) @@ -193,7 +193,11 @@ async fn tags_page(cx: &Cx) -> Result { Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) - refs_table(rows: rows, kind_label: g::t(lang, K::TagKindLabel), lang: lang) +
+
+ refs_table(rows: rows, kind_label: g::t(lang, K::TagKindLabel), lang: lang) +
+
) }) } diff --git a/crates/forge-web/src/pages/register.rs b/crates/forge-web/src/pages/register.rs index e1b71cc..3786888 100644 --- a/crates/forge-web/src/pages/register.rs +++ b/crates/forge-web/src/pages/register.rs @@ -564,7 +564,10 @@ mod tests { let (status, _, html) = send(&router, "GET", "/register?invite=forge_nope", None, None).await; assert_eq!(status, 200, "bad invite: status"); - assert!(html.contains("This invite is invalid"), "bad invite: notice"); + assert!( + html.contains("This invite is invalid"), + "bad invite: notice" + ); // Case: a valid invite creates one verified account with the invited address. let admin = state diff --git a/crates/forge-web/src/pages/releases.rs b/crates/forge-web/src/pages/releases.rs index b27d19d..adb9643 100644 --- a/crates/forge-web/src/pages/releases.rs +++ b/crates/forge-web/src/pages/releases.rs @@ -25,7 +25,9 @@ use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; use topcoat::router::request::headers; use topcoat::router::response::Response; -use topcoat::router::{Body, HeaderName, HeaderValue, StatusCode, page, path_param, query_params, route}; +use topcoat::router::{ + Body, HeaderName, HeaderValue, StatusCode, page, path_param, query_params, route, +}; use topcoat::view::{Unescaped, View, component, view}; use crate::auth::require_csrf; @@ -34,11 +36,11 @@ use crate::i18n::{ self, Key, Lang, releases_ci::{self as g, K}, }; +use crate::pages::issue_parts::When; use crate::pages::refs::load_refs; use crate::pages::releases_live; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::issue_parts::When; use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError}; use crate::render::markdown::render_markdown; use crate::state::AppState; @@ -502,23 +504,19 @@ async fn list_body(
(text)
} } -
-
+
+

(g::t(lang, K::Releases))

if let Some(href) = &new_href { - (g::t(lang, K::NewRelease)) + (g::t(lang, K::NewRelease)) }
if cards.is_empty() { - empty_state(title: g::t(lang, K::NoReleasesYet), - if let Some(href) = &new_href { - (g::t(lang, K::NewRelease)) - } - ) + empty_state(title: g::t(lang, K::NoReleasesYet)) } -
+
for card in cards.iter() { -
+

(card.title.as_str()) if card.latest { @@ -637,7 +635,7 @@ async fn new_form_body( ) -> Result { Ok(view! { repo_head(head: head) -
+

(g::t(lang, K::NewRelease))

release_form(action: action, csrf: csrf, lang: lang, is_new: true, move_target: true, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease))
@@ -908,12 +906,13 @@ async fn edit_body(
(text)
} } -
+
+

(g::t(lang, K::BackToRelease))

(g::t(lang, K::EditRelease))

release_form(action: action, csrf: csrf.clone(), lang: lang, is_new: false, move_target: move_target, draft: draft, branches: branches, submit: g::t(lang, K::SaveRelease))
-
+

(g::t(lang, K::Assets))

(upload_hint.as_str())

asset_rows(assets: assets, delete_actions: delete_actions, upload_action: upload_action.clone(), csrf: csrf.clone(), lang: lang) @@ -927,8 +926,6 @@ async fn edit_body(
-
-

(g::t(lang, K::DeleteRelease))

(g::t(lang, K::DeleteReleaseHelp))

@@ -946,6 +943,7 @@ async fn edit_body(
+

}) } diff --git a/crates/forge-web/src/pages/repo.rs b/crates/forge-web/src/pages/repo.rs index 79b4fa3..420854a 100644 --- a/crates/forge-web/src/pages/repo.rs +++ b/crates/forge-web/src/pages/repo.rs @@ -20,24 +20,24 @@ use topcoat::view::{View, component, view}; use crate::i18n::code::{self as g, K}; use crate::i18n::{self, Lang}; -use crate::pages::passkeys::s; use crate::pages::code_live::{follows_branch, home_live_url}; use crate::pages::finder::file_finder; -use crate::pages::repo_side::{ - StripFacts, commit_strip, commit_subject, readme_meta, repo_dock, repo_strip, run_rows, - run_states, strip_bars, tree_facts, -}; use crate::pages::issue_parts::stamp_unix; use crate::pages::notifications::watch_form; use crate::pages::packages; +use crate::pages::passkeys::s; use crate::pages::refs::{load_refs, ref_links}; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; +use crate::pages::repo_side::{ + StripFacts, commit_strip, readme_meta, repo_dock, repo_strip, run_rows, run_states, strip_bars, + tree_facts, +}; use crate::pages::tree::{ entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_card, tree_table, }; use crate::state::AppState; use crate::views::repo_list::badge_class; -use crate::views::{now_unix, ref_selector, rel_time, relative_time, repo_href, repo_tabs, shell, user_link}; +use crate::views::{now_unix, ref_selector, rel_time, relative_time, repo_href, repo_tabs, shell}; path_param!(owner); path_param!(repo); @@ -93,12 +93,8 @@ pub async fn repo_head(head: RepoHead) -> Result { wiki, security, lang, - compact_tabs, .. } = head; - // The title gets its own copies: the view below moves `owner` and `name` into `repo_tabs`. - let title_owner = owner.clone(); - let title_name = name.clone(); let badge = badge_class(visibility); let vis = i18n::visibility_label(lang, visibility); let active = active.to_owned(); @@ -154,22 +150,14 @@ pub async fn repo_head(head: RepoHead) -> Result { None => ("", "", None, String::new()), }; let live_attr = (!live.is_empty()).then(|| live.clone()); - // The Code tab has no title row: the path bar names the repo, and the tabs share a row with + // Every repo page has one head row: the path bar names the repo, and the tabs share a row with // the visibility and the counts and actions at the right end. - let code = active == "code"; - // One row for the tabs: the Code tab, or a page that asks for it (`compact_tabs`). - let tabs_head = code || compact_tabs; let has_origin = fork_line.is_some() || mirror_line.is_some(); Ok(view! { -
- if !tabs_head || has_origin { +
+

(owner.as_str()) "/" (name.as_str())

+ if has_origin {
- if !tabs_head { -
-

user_link(shown: title_owner.as_str(), login: title_owner.as_str()) "/" (title_name.as_str())

- (vis) -
- } if let Some((href, label)) = fork_line {

(g::t(lang, K::ForkedFrom)) (label.as_str())

} @@ -184,13 +172,9 @@ pub async fn repo_head(head: RepoHead) -> Result { }
} - if tabs_head { - repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) - } + repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security)
- if tabs_head { - (vis) - } + (vis) if let Some((action, csrf)) = fork_control {
@@ -221,12 +205,9 @@ pub async fn repo_head(head: RepoHead) -> Result {
} // The description belongs to the Code tab only; sub-pages keep the compact head. - if code && !description.is_empty() { + if active == "code" && !description.is_empty() {

(description.as_str())

} - if !tabs_head { - repo_tabs(owner: owner.clone(), repo: name.clone(), default_branch: default_branch.clone(), active: active.clone(), can_admin: can_admin, lang: lang, open_issues: Some(open_issues), open_pulls: Some(open_pulls), discussions: discussions, wiki: wiki, security: security) - } }) } @@ -507,7 +488,12 @@ async fn repo_page(cx: &Cx) -> Result { let now = now_unix(); let downloads = ( repo_href(&owner_name, &repo_name, "archive", &format!("{branch}.zip")), - repo_href(&owner_name, &repo_name, "archive", &format!("{branch}.tar.gz")), + repo_href( + &owner_name, + &repo_name, + "archive", + &format!("{branch}.tar.gz"), + ), ); // The dock: the history strip of the newest commits (cached per head) and the latest run's // commit subject. Empty repos have no tree, so they have no dock. @@ -518,10 +504,6 @@ async fn repo_page(cx: &Cx) -> Result { let ci_states = run_states(state, &repo.id).await?; let bars = strip_bars(&strip.commits, &ci_states); let total = strip.total; - let subject = match runs.first() { - Some(run) => commit_subject(state, &ctx.path, &run.commit).await, - None => None, - }; let search_href = repo_href(&owner_name, &repo_name, "search", ""); let show_search = !header.hide_search; let has_chips = latest.is_some() || !packages.is_empty(); @@ -543,7 +525,7 @@ async fn repo_page(cx: &Cx) -> Result { file_finder(lang: lang, owner: owner_name.clone(), repo: repo_name.clone(), ref_name: branch.clone()) if show_search { - (g::t(lang, K::SearchCodePlaceholder)) + (g::t(lang, K::SearchCodePlaceholder)) } clone_popover(https: https, ssh: ssh, downloads: Some(downloads), lang: lang)
@@ -559,7 +541,7 @@ async fn repo_page(cx: &Cx) -> Result { }
- repo_dock(lang: lang, runs: runs, subject: subject, total: total, ci_href: ci_href, + repo_dock(lang: lang, runs: runs, total: total, ci_href: ci_href, owner: owner_name.clone(), repo: repo_name.clone(), bars: bars) } else {
diff --git a/crates/forge-web/src/pages/repo_collaborators.rs b/crates/forge-web/src/pages/repo_collaborators.rs index e8f12df..c8bbc55 100644 --- a/crates/forge-web/src/pages/repo_collaborators.rs +++ b/crates/forge-web/src/pages/repo_collaborators.rs @@ -28,7 +28,7 @@ use crate::i18n::{self, Lang}; use crate::pages::passkeys; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::repo_settings::settings_nav_for; +use crate::pages::repo_settings::settings_frame; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; use crate::views::{alert, avatar_url, display_name, empty_state, shell}; @@ -306,7 +306,7 @@ async fn collaborators_body( let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); Ok(view! { repo_head(head: header) - settings_nav_for(lang: lang, title: nav_title, current: "collaborators") + settings_frame(lang: lang, title: nav_title, current: "collaborators", if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -326,6 +326,7 @@ async fn collaborators_body(
role_legend(lang: lang)
+ ) }) } diff --git a/crates/forge-web/src/pages/repo_ctx.rs b/crates/forge-web/src/pages/repo_ctx.rs index 20a3a1f..d1a6721 100644 --- a/crates/forge-web/src/pages/repo_ctx.rs +++ b/crates/forge-web/src/pages/repo_ctx.rs @@ -60,9 +60,6 @@ pub struct RepoHead { pub active: &'static str, /// Hide the header's code-search box (the code search page draws its own). pub hide_search: bool, - /// One row for the header: no title row, the tabs at the left and the counts and actions at the - /// right, as on the Code tab. Set by the pages that have their own top (the CI run page). - pub compact_tabs: bool, /// Whether the viewer may open the Settings tab. pub can_admin: bool, /// Open issues, for the Issues tab count. @@ -239,7 +236,6 @@ impl RepoCtx { last_ok: mirror.last_ok, }); Ok(RepoHead { - compact_tabs: false, lang: self.lang, owner: self.repo.owner_name.clone(), name: self.repo.name.clone(), diff --git a/crates/forge-web/src/pages/repo_mirrors.rs b/crates/forge-web/src/pages/repo_mirrors.rs index 745edc2..79abc9b 100644 --- a/crates/forge-web/src/pages/repo_mirrors.rs +++ b/crates/forge-web/src/pages/repo_mirrors.rs @@ -21,7 +21,7 @@ use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; use topcoat::router::request::uri; use topcoat::router::{page, path_param, route}; -use topcoat::view::{View, component, view}; +use topcoat::view::{Child, View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; @@ -33,10 +33,12 @@ use crate::i18n::{ use crate::pages::refs::load_refs; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::repo_settings::settings_nav_for; +use crate::pages::repo_settings::settings_frame; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; -use crate::views::{alert, empty_state, enc, now_unix, rel_time_or_never, relative_time, shell, user_facing_message}; +use crate::views::{ + alert, empty_state, enc, now_unix, rel_time_or_never, relative_time, shell, user_facing_message, +}; use crate::webhooks::client::{WebhookPolicy, validate_url}; path_param!(owner); @@ -392,10 +394,11 @@ async fn frame_top( notice: Option<(&'static str, bool)>, archived: bool, lang: Lang, + #[default] child: Child<'_>, ) -> Result { Ok(view! { repo_head(head: head) - settings_nav_for(lang: lang, title: title, current: "mirrors") + settings_frame(lang: lang, title: title, current: "mirrors", if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -406,6 +409,8 @@ async fn frame_top( if archived {
(g::t(lang, K::ArchivedNotice))
} + (child) + ) }) } @@ -506,7 +511,7 @@ async fn mirrors_list_body( let add_action = mirrors_href(&title); let can_pull = pull_form.is_some(); Ok(view! { - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) + frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang,

(g::t(lang, K::Mirrors))

@@ -577,6 +582,7 @@ async fn mirrors_list_body(
}
+ ) }) } @@ -797,7 +803,7 @@ async fn mirror_body( }; let current_url = redacted_url(&mirror.url); Ok(view! { - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) + frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang,

(mirror_kind(lang, mirror.direction))

if archived { @@ -841,6 +847,7 @@ async fn mirror_body(
} + ) }) } @@ -1257,16 +1264,13 @@ mod tests { .set_ui_prefs(&tahinli.id, "auto", "tr") .await .expect("set language"); - let (status, _, body) = send( - &app, - "GET", - "/tahinli/proj/settings/mirrors", - &cookie, - &[], - ) - .await; + let (status, _, body) = + send(&app, "GET", "/tahinli/proj/settings/mirrors", &cookie, &[]).await; assert_eq!(status, 200, "{body}"); - assert!(body.contains("

Yansılar

"), "Turkish heading missing"); + assert!( + body.contains("

Yansılar

"), + "Turkish heading missing" + ); } /// The push form refuses a loopback destination and stores nothing, then adds a good mirror @@ -1495,5 +1499,4 @@ mod tests { assert!(store.pull_mirror(&repo.id).await.expect("query").is_none()); assert!(store.list_mirrors(&repo.id).await.expect("list").is_empty()); } - } diff --git a/crates/forge-web/src/pages/repo_rename.rs b/crates/forge-web/src/pages/repo_rename.rs index 79f5a55..46e84a8 100644 --- a/crates/forge-web/src/pages/repo_rename.rs +++ b/crates/forge-web/src/pages/repo_rename.rs @@ -22,7 +22,7 @@ use crate::i18n::repo_admin::{self as g, K}; use crate::i18n::{self, Lang}; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::repo_settings::settings_nav_for; +use crate::pages::repo_settings::settings_frame; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; use crate::views::{alert, shell}; @@ -120,7 +120,7 @@ async fn rename_body( } = forms; Ok(view! { repo_head(head: head) - settings_nav_for(lang: lang, title: nav_title, current: "rename") + settings_frame(lang: lang, title: nav_title, current: "rename", if let Some(key) = notice {
(g::t(lang, key))
} @@ -164,6 +164,7 @@ async fn rename_body( } + ) }) } diff --git a/crates/forge-web/src/pages/repo_secrets.rs b/crates/forge-web/src/pages/repo_secrets.rs index c1af9ed..e67375d 100644 --- a/crates/forge-web/src/pages/repo_secrets.rs +++ b/crates/forge-web/src/pages/repo_secrets.rs @@ -12,7 +12,7 @@ use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; use topcoat::router::request::uri; use topcoat::router::{page, path_param, route}; -use topcoat::view::{View, component, view}; +use topcoat::view::{Child, View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; @@ -20,7 +20,7 @@ use crate::i18n::repo_admin::{self as g, K}; use crate::i18n::{self, Lang}; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::repo_settings::settings_nav_for; +use crate::pages::repo_settings::settings_frame; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; use crate::views::{alert, empty_state, enc, rel_time, shell}; @@ -155,11 +155,12 @@ async fn frame_top( title: String, notice: Option<(K, bool)>, archived: bool, + #[default] child: Child<'_>, ) -> Result { let notice = notice.map(|(key, is_error)| (g::t(lang, key), is_error)); Ok(view! { repo_head(head: head) - settings_nav_for(lang: lang, title: title, current: "secrets") + settings_frame(lang: lang, title: title, current: "secrets", if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -170,6 +171,8 @@ async fn frame_top( if archived {
(g::t(lang, K::ArchivedSecrets))
} + (child) + ) }) } @@ -190,7 +193,7 @@ async fn secrets_body( let set_action = secrets_href(&title); let delete_action = format!("{set_action}/delete"); Ok(view! { - frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived) + frame_top(lang: lang, head: head, title: title.clone(), notice: notice, archived: archived,

(g::t(lang, K::Secrets))

@@ -257,6 +260,7 @@ async fn secrets_body(
}
+ ) }) } diff --git a/crates/forge-web/src/pages/repo_security.rs b/crates/forge-web/src/pages/repo_security.rs index 1a4bcaa..3dcbad2 100644 --- a/crates/forge-web/src/pages/repo_security.rs +++ b/crates/forge-web/src/pages/repo_security.rs @@ -121,16 +121,17 @@ async fn security_body( let open_count = rows.iter().filter(|r| r.open).count(); Ok(view! { repo_head(head: head) -
-

(i18n::t(lang, Key::Security))

- if !enabled { -

(g::t(lang, K::SecurityOff))

- } else { -

(g::dependencies_summary(lang, dependencies, open_count))

-

(g::t(lang, K::LockfilesRead))

- } -
-
+
+
+

(i18n::t(lang, Key::Security))

+ if !enabled { +

(g::t(lang, K::SecurityOff))

+ } else { +

(g::dependencies_summary(lang, dependencies, open_count))

+

(g::t(lang, K::LockfilesRead))

+ } +
+
if rows.is_empty() { empty_state(title: g::t(lang, K::NoAlerts)) } else { @@ -150,7 +151,7 @@ async fn security_body( for row in rows.iter() { - + (row.advisory.as_str()) (row.package.as_str()) (row.version.as_str()) @@ -186,6 +187,7 @@ async fn security_body(
} +
}) } diff --git a/crates/forge-web/src/pages/repo_settings.rs b/crates/forge-web/src/pages/repo_settings.rs index a74d800..515a279 100644 --- a/crates/forge-web/src/pages/repo_settings.rs +++ b/crates/forge-web/src/pages/repo_settings.rs @@ -26,7 +26,7 @@ use topcoat::cookie::{Cookie, Cookies, SameSite, cookies}; use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, see_other}; use topcoat::router::{page, path_param, route}; -use topcoat::view::{View, component, view}; +use topcoat::view::{Child, View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; @@ -268,13 +268,15 @@ async fn danger_zone( }) } -/// Sub-navigation for the settings pages. `current` names the page shown (`general` or `webhooks`) -/// and gets `aria-current`. +/// The settings frame: the sections in a left pane and the page's own content (its children) in a +/// right pane. Both fill the window below the repo head (see `.settings-layout` in `_lang_browse.scss`). +/// `current` names the section shown (`general`, `webhooks`, ...) and gets `aria-current`. #[component] -pub async fn settings_nav_for( +pub async fn settings_frame( lang: Lang, title: String, current: &'static str, + #[default] child: Child<'_>, ) -> Result { let general = format!("/{title}/settings"); let collaborators = format!("/{title}/settings/collaborators"); @@ -288,7 +290,10 @@ pub async fn settings_nav_for( let hooks_on = current == "webhooks"; let mirrors_on = current == "mirrors"; let secrets_on = current == "secrets"; + let wiki = format!("/{title}/settings/wiki"); + let wiki_on = current == "wiki"; Ok(view! { +
+
+ (child) +
+
}) } @@ -341,21 +355,22 @@ async fn general_section( let visibility_action = format!("/{title}/settings/visibility"); let archive_action = format!("/{title}/settings/archive"); // The visibility row shows where the repo is now and offers the other side behind a confirm. - let (current_visibility, flip_label, flip_confirm, flip_to) = if visibility == Visibility::Public { - ( - g::t(lang, K::PublicOption), - g::t(lang, K::MakePrivate), - g::t(lang, K::MakePrivateConfirm), - "private", - ) - } else { - ( - g::t(lang, K::PrivateOption), - g::t(lang, K::MakePublic), - g::t(lang, K::MakePublicConfirm), - "public", - ) - }; + let (current_visibility, flip_label, flip_confirm, flip_to) = + if visibility == Visibility::Public { + ( + g::t(lang, K::PublicOption), + g::t(lang, K::MakePrivate), + g::t(lang, K::MakePrivateConfirm), + "private", + ) + } else { + ( + g::t(lang, K::PrivateOption), + g::t(lang, K::MakePublic), + g::t(lang, K::MakePublicConfirm), + "public", + ) + }; let options: Vec<(String, bool)> = branches .into_iter() .map(|b| { @@ -496,7 +511,10 @@ fn rule_pills(lang: Lang, rule: &BranchRule) -> Vec { pills.push(pill(g::t(lang, K::DeletionAllowed), warn)); } if rule.required_approvals > 0 { - pills.push(pill(&g::approvals_count(lang, rule.required_approvals), plain)); + pills.push(pill( + &g::approvals_count(lang, rule.required_approvals), + plain, + )); } if rule.restrict_push { pills.push(pill(g::t(lang, K::RulePrOnly), plain)); @@ -839,7 +857,7 @@ async fn settings_body( // danger zone. The pane holds them to one screen (see _fit_settings.scss). Ok(view! { repo_head(head: head) - settings_nav_for(lang: lang, title: title.clone(), current: "general") + settings_frame(lang: lang, title: title.clone(), current: "general", if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -869,6 +887,7 @@ async fn settings_body( } + ) }) } diff --git a/crates/forge-web/src/pages/repo_side.rs b/crates/forge-web/src/pages/repo_side.rs index f14106c..9f62002 100644 --- a/crates/forge-web/src/pages/repo_side.rs +++ b/crates/forge-web/src/pages/repo_side.rs @@ -7,8 +7,8 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::{Mutex, OnceLock}; -use forge_core::ci::{JobState, RunState}; use forge_core::Repo; +use forge_core::ci::{JobState, RunState}; use forge_git::churn::{self, CommitChurn}; use forge_git::{browse, history}; use time::OffsetDateTime; @@ -26,7 +26,6 @@ use crate::pages::passkeys::s; use crate::pages::releases::LatestRelease; use crate::repo_stats::{LangShare, languages, license_file, license_id}; use crate::state::AppState; -use crate::views::commit_line::commit_line; use crate::views::timeline::{StripBar, history_strip}; use crate::views::{human_size, now_unix, rel_time, short_oid}; @@ -185,16 +184,6 @@ pub fn strip_bars(commits: &[CommitChurn], ci: &HashMap) -> Ve .collect() } -/// The subject of a commit, for the CI line. None when it cannot be read. -pub async fn commit_subject(state: &AppState, path: &Path, oid: &str) -> Option { - history::log(&state.git, path, oid, None, 0, 1) - .await - .ok()? - .into_iter() - .next() - .map(|commit| commit.summary) -} - /// One CI run as the column shows it: a link to the run, its dot, and one line of words. A run /// still going has a clock that ticks. pub struct RunRow { @@ -249,7 +238,10 @@ pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result Vec { let slice = LangSlice { x: format!("{at}%"), width: format!("{}%", share.percent), - class: if share.others.is_empty() { SHADES[i.min(3)] } else { SHADES[4] }, + class: if share.others.is_empty() { + SHADES[i.min(3)] + } else { + SHADES[4] + }, }; at += share.percent; slice @@ -464,7 +460,11 @@ pub async fn readme_meta(lang: Lang, facts: Option) -> Result = Vec::new(); if let Some((file, id)) = facts.license.as_ref() { - parts.push(if id.is_empty() { file.clone() } else { id.clone() }); + parts.push(if id.is_empty() { + file.clone() + } else { + id.clone() + }); } if facts.size > 0 { parts.push(human_size(lang, facts.size)); @@ -497,7 +497,6 @@ pub async fn readme_meta(lang: Lang, facts: Option) -> Result, - subject: Option, total: u64, ci_href: String, owner: String, @@ -520,9 +519,6 @@ pub async fn repo_dock( (state_text(lang, run.state.as_str())) (short_oid(&run.commit)) - if let Some(subject) = subject.as_ref() { - commit_line(subject: subject.clone()) - } if let Some(since) = run.since.as_deref() { if let Some(est) = run.est.as_ref() { (run.label.as_str()) @@ -553,7 +549,11 @@ fn release_counts(lang: Lang, release: &LatestRelease) -> String { Lang::En => format!( " \u{b7} {assets} {} \u{b7} {downloads} {}", if assets == 1 { "asset" } else { "assets" }, - if downloads == 1 { "download" } else { "downloads" } + if downloads == 1 { + "download" + } else { + "downloads" + } ), } } diff --git a/crates/forge-web/src/pages/repo_webhooks.rs b/crates/forge-web/src/pages/repo_webhooks.rs index 7948274..ee6660f 100644 --- a/crates/forge-web/src/pages/repo_webhooks.rs +++ b/crates/forge-web/src/pages/repo_webhooks.rs @@ -18,7 +18,7 @@ use topcoat::router::content::Form; use topcoat::router::error::{SeeOther, forbidden, not_found, see_other}; use topcoat::router::request::uri; use topcoat::router::{page, path_param, route}; -use topcoat::view::{View, component, view}; +use topcoat::view::{Child, View, component, view}; use crate::audit::{self, Actor, Target}; use crate::auth::{require_csrf, require_user}; @@ -28,7 +28,7 @@ use crate::i18n::{ }; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo}; -use crate::pages::repo_settings::settings_nav_for; +use crate::pages::repo_settings::settings_frame; use crate::pages::repo_settings_live::settings_head; use crate::state::AppState; use crate::views::{alert, empty_state, enc, now_unix, relative_time, shell}; @@ -493,10 +493,11 @@ async fn frame_top( notice: Option<(&'static str, bool)>, archived: bool, lang: Lang, + #[default] child: Child<'_>, ) -> Result { Ok(view! { repo_head(head: head) - settings_nav_for(lang: lang, title: title, current: "webhooks") + settings_frame(lang: lang, title: title, current: "webhooks", if let Some((text, is_error)) = notice { if is_error { alert(message: text) @@ -507,6 +508,8 @@ async fn frame_top( if archived {
(g::t(lang, K::HookArchivedNotice))
} + (child) + ) }) } @@ -570,7 +573,7 @@ async fn hooks_list_body( ) -> Result { let new_href = format!("{}/new", hooks_href(&title)); Ok(view! { - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) + frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang,

(g::t(lang, K::Webhooks))

(g::t(lang, K::WebhooksIntro))

@@ -613,6 +616,7 @@ async fn hooks_list_body( }
+ ) }) } @@ -685,7 +689,7 @@ async fn hook_body( let delete_action = format!("{edit_action}/delete"); let events = event_boxes(lang, &draft.events); Ok(view! { - frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang) + frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang,

(g::t(lang, K::EditWebhook))

if archived { @@ -732,6 +736,7 @@ async fn hook_body(
} + ) }) } @@ -811,7 +816,7 @@ async fn hook_new_body( let events = event_boxes(lang, &draft.events); let back = hooks_href(&title); Ok(view! { - frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang) + frame_top(head: head, title: title.clone(), notice: None, archived: archived, lang: lang,

(g::t(lang, K::AddWebhook))

@@ -822,6 +827,7 @@ async fn hook_new_body(

(g::t(lang, K::BackToWebhooks))

+ ) }) } diff --git a/crates/forge-web/src/pages/review_requests.rs b/crates/forge-web/src/pages/review_requests.rs index 359b1c5..98c9953 100644 --- a/crates/forge-web/src/pages/review_requests.rs +++ b/crates/forge-web/src/pages/review_requests.rs @@ -292,7 +292,7 @@ async fn review_requests(cx: &Cx) -> Result { empty_state(title: ga::t(lang, AK::NoReviewRequests)) } if !empty { -
+
    for row in rows.iter() {
  • diff --git a/crates/forge-web/src/pages/settings_appearance.rs b/crates/forge-web/src/pages/settings_appearance.rs index f649da9..6177260 100644 --- a/crates/forge-web/src/pages/settings_appearance.rs +++ b/crates/forge-web/src/pages/settings_appearance.rs @@ -588,7 +588,11 @@ pub fn sidebar_stored(stored: &str) -> &'static str { /// Builds the page for a viewer. Each choice shows the stored value, or the default when the /// stored id is no longer offered, which is what the page renders on `` too. -fn page_for(viewer: &(User, Session), lang: Lang, prefs: &HashMap) -> AppearancePage { +fn page_for( + viewer: &(User, Session), + lang: Lang, + prefs: &HashMap, +) -> AppearancePage { let user = &viewer.0; let density = match prefs.get(DENSITY).map(String::as_str) { Some("compact") => "compact", @@ -796,7 +800,9 @@ mod tests { "accent upper case {id}" ); } - for id in ["fern", "spark", "graphite", "dusk", "ink", "anvil", "hue-120"] { + for id in [ + "fern", "spark", "graphite", "dusk", "ink", "anvil", "hue-120", + ] { assert_eq!( base_choice(Lang::Tr, Some(id), "fern").unwrap(), id, diff --git a/crates/forge-web/src/pages/settings_gpg.rs b/crates/forge-web/src/pages/settings_gpg.rs index bcd43d1..7a381a9 100644 --- a/crates/forge-web/src/pages/settings_gpg.rs +++ b/crates/forge-web/src/pages/settings_gpg.rs @@ -50,7 +50,7 @@ async fn gpg_view( if !available {

    (t(lang, Key::GpgUnavailable))

    } -
    +
    if keys.is_empty() { empty_state(title: t(lang, Key::NoGpgKeys), (t(lang, Key::AddGpgKeyTitle))) diff --git a/crates/forge-web/src/pages/settings_gpg_tests.rs b/crates/forge-web/src/pages/settings_gpg_tests.rs index d8f3cb3..2fb363e 100644 --- a/crates/forge-web/src/pages/settings_gpg_tests.rs +++ b/crates/forge-web/src/pages/settings_gpg_tests.rs @@ -132,7 +132,14 @@ async fn gpg_refusals_and_the_listing_share_one_site() { .await .unwrap(); let anon_fields = [("csrf", CSRF), ("id", key.id.as_str())]; - let anon = call(&site, "POST", "/settings/gpg/delete", None, Some(&anon_fields)).await; + let anon = call( + &site, + "POST", + "/settings/gpg/delete", + None, + Some(&anon_fields), + ) + .await; assert_eq!(anon.status, 303, "anonymous delete"); let bad_delete = [("csrf", "wrong"), ("id", key.id.as_str())]; let reply = call( @@ -153,8 +160,14 @@ async fn gpg_refusals_and_the_listing_share_one_site() { // The page lists the key. The notice shows only when GPG is missing on this server. let reply = call(&site, "GET", "/settings/gpg", Some(&cookie), None).await; assert_eq!(reply.status, 200, "listing page"); - assert!(reply.body.contains(FINGERPRINT), "listing shows the fingerprint"); - assert!(reply.body.contains("tahinli@example.com"), "listing shows the email"); + assert!( + reply.body.contains(FINGERPRINT), + "listing shows the fingerprint" + ); + assert!( + reply.body.contains("tahinli@example.com"), + "listing shows the email" + ); let notice = "GPG verification is unavailable on this server"; assert_eq!(reply.body.contains(notice), !available, "notice"); } @@ -175,7 +188,12 @@ async fn owners_delete_their_own_keys_and_no_one_elses() { .unwrap(); let bob_key = site .store - .add_gpg_key(&bob.id, BOB_FINGERPRINT, "armored", &["bob@example.com".into()]) + .add_gpg_key( + &bob.id, + BOB_FINGERPRINT, + "armored", + &["bob@example.com".into()], + ) .await .unwrap(); let own_key = site diff --git a/crates/forge-web/src/pages/settings_keys.rs b/crates/forge-web/src/pages/settings_keys.rs index 78c435f..b3e3844 100644 --- a/crates/forge-web/src/pages/settings_keys.rs +++ b/crates/forge-web/src/pages/settings_keys.rs @@ -147,7 +147,7 @@ async fn keys_view(

    (t(lang, Key::SshKeys))

    -
    +
    if keys.is_empty() { empty_state(title: t(lang, Key::NoSshKeys), (t(lang, Key::AddSshKeyTitle))) @@ -308,9 +308,27 @@ mod tests { .collect::>() .join(" "); let cases = [ - ("ed25519 with comment", ED25519.to_owned(), "ssh-ed25519", "test@forge", ED25519_FP), - ("ed25519 bare and padded", format!(" {bare}\n"), "ssh-ed25519", "", ED25519_FP), - ("ecdsa", ECDSA.to_owned(), "ecdsa-sha2-nistp256", "tahinli@tFedora", ECDSA_FP), + ( + "ed25519 with comment", + ED25519.to_owned(), + "ssh-ed25519", + "test@forge", + ED25519_FP, + ), + ( + "ed25519 bare and padded", + format!(" {bare}\n"), + "ssh-ed25519", + "", + ED25519_FP, + ), + ( + "ecdsa", + ECDSA.to_owned(), + "ecdsa-sha2-nistp256", + "tahinli@tFedora", + ECDSA_FP, + ), ]; for (name, input, algorithm, comment, fingerprint) in cases { let parsed = parse_public_key(&input).unwrap_or_else(|e| panic!("case {name}: {e:?}")); @@ -337,18 +355,38 @@ mod tests { let relabelled = ED25519.replacen("ssh-ed25519", "ecdsa-sha2-nistp256", 1); let huge = format!("ssh-ed25519 {}", "A".repeat(MAX_KEY_CHARS)); let cases = [ - ("rsa", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn test@host".to_owned(), KeyProblem::Rsa), + ( + "rsa", + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn test@host".to_owned(), + KeyProblem::Rsa, + ), ( "dss", "ssh-dss AAAAB3NzaC1kc3MAAACBAP test@host".to_owned(), KeyProblem::UnsupportedType("ssh-dss".into()), ), ("relabelled", relabelled, KeyProblem::Mismatch), - ("bad base64", "ssh-ed25519 !!!notbase64".to_owned(), KeyProblem::BadBase64), - ("truncated", "ssh-ed25519 AAAA".to_owned(), KeyProblem::Truncated), - ("length past the end", format!("ssh-ed25519 {body}"), KeyProblem::Truncated), + ( + "bad base64", + "ssh-ed25519 !!!notbase64".to_owned(), + KeyProblem::BadBase64, + ), + ( + "truncated", + "ssh-ed25519 AAAA".to_owned(), + KeyProblem::Truncated, + ), + ( + "length past the end", + format!("ssh-ed25519 {body}"), + KeyProblem::Truncated, + ), ("empty", " ".to_owned(), KeyProblem::Empty), - ("no key body", "ssh-ed25519".to_owned(), KeyProblem::MissingBody), + ( + "no key body", + "ssh-ed25519".to_owned(), + KeyProblem::MissingBody, + ), ("too long", huge, KeyProblem::TooLong), ]; for (name, input, want) in cases { diff --git a/crates/forge-web/src/pages/settings_profile.rs b/crates/forge-web/src/pages/settings_profile.rs index 863efa5..b93b8d8 100644 --- a/crates/forge-web/src/pages/settings_profile.rs +++ b/crates/forge-web/src/pages/settings_profile.rs @@ -318,7 +318,10 @@ pub(crate) async fn store_avatar( }; // Decoding and resizing are CPU-bound; keep them off the async workers. A decode can take // around 128 MiB, so only a couple run at once. - let _permit = avatar_slots().acquire().await.map_err(std::io::Error::other)?; + let _permit = avatar_slots() + .acquire() + .await + .map_err(std::io::Error::other)?; let joined = tokio::task::spawn_blocking(move || process_avatar(&bytes)).await; let processed = joined.map_err(std::io::Error::other)??; store diff --git a/crates/forge-web/src/pages/settings_security.rs b/crates/forge-web/src/pages/settings_security.rs index da24ce5..abd60a4 100644 --- a/crates/forge-web/src/pages/settings_security.rs +++ b/crates/forge-web/src/pages/settings_security.rs @@ -241,7 +241,7 @@ async fn security_body(page: SecurityPage) -> Result {

    (t(lang, Key::Security))

    -

    (t(lang, Key::SecurityLog))(t(lang, Key::SecurityLogRest))

    +

    (t(lang, Key::SecurityLog))(t(lang, Key::SecurityLogRest))

    if let Some(message) = notice {
    diff --git a/crates/forge-web/src/pages/settings_sessions.rs b/crates/forge-web/src/pages/settings_sessions.rs index 667c8bc..20d487e 100644 --- a/crates/forge-web/src/pages/settings_sessions.rs +++ b/crates/forge-web/src/pages/settings_sessions.rs @@ -59,8 +59,14 @@ async fn sessions_view( Ok(view! {

    (t(lang, Key::Sessions))

    + if others > 0 { +
    + + +
    + }
    -
    +
      for session in sessions.into_iter() {
    • @@ -91,14 +97,6 @@ async fn sessions_view( }
    - if others > 0 { -
    -
    - - -
    -
    - } }) } diff --git a/crates/forge-web/src/pages/settings_tokens.rs b/crates/forge-web/src/pages/settings_tokens.rs index 4ce6036..ff0d144 100644 --- a/crates/forge-web/src/pages/settings_tokens.rs +++ b/crates/forge-web/src/pages/settings_tokens.rs @@ -100,7 +100,7 @@ async fn tokens_view(

    (t(lang, Key::UseAsPassword))

    } -
    +
    if tokens.is_empty() { empty_state(title: t(lang, Key::NoAccessTokens), (t(lang, Key::NewToken))) diff --git a/crates/forge-web/src/pages/snippets.rs b/crates/forge-web/src/pages/snippets.rs index 5ba77b7..5a9869c 100644 --- a/crates/forge-web/src/pages/snippets.rs +++ b/crates/forge-web/src/pages/snippets.rs @@ -305,7 +305,7 @@ async fn snippet_list_body( (g::t(lang, K::NewSnippet)) }
    -
    +
    if rows.is_empty() { empty_state(title: g::t(lang, K::NoSnippets), if signed_in { @@ -422,7 +422,7 @@ async fn snippet_form( }
    -
    +

    (heading)

    @@ -535,7 +535,7 @@ async fn revisions_body(

    (heading.as_str())

    (g::t(lang, K::BackToSnippet))
    -
    +
    if revisions.is_empty() {

    (g::t(lang, K::NoRevisions))

    } else { @@ -589,10 +589,7 @@ async fn snippets_list(cx: &Cx) -> Result { .store .list_snippets(viewer_id.as_deref()) .await?; - let rows: Vec = summaries - .into_iter() - .map(|s| list_row(lang, s)) - .collect(); + let rows: Vec = summaries.into_iter().map(|s| list_row(lang, s)).collect(); let signed_in = viewer.is_some(); let title = g::t(lang, K::Snippets); Ok(view! { @@ -859,10 +856,17 @@ mod tests { ("name_2", "b.rs"), ("content_2", ""), ])); - assert_eq!(draft.files.len(), 3, "blank cards: every card is kept while editing"); + assert_eq!( + draft.files.len(), + 3, + "blank cards: every card is kept while editing" + ); let saved = draft.saved_files(); assert_eq!(saved.len(), 2, "blank cards: a save drops the blank ones"); - assert_eq!(saved[0].content, "one\ntwo", "blank cards: CRLF is normalised"); + assert_eq!( + saved[0].content, "one\ntwo", + "blank cards: CRLF is normalised" + ); assert_eq!(saved[1].name, "b.rs", "blank cards: the kept file"); // Case: a leading newline in a file survives the textarea. @@ -913,7 +917,11 @@ mod tests { draft.remove(0); let numbers: Vec = draft.slots().iter().map(|s| s.number).collect(); assert_eq!(numbers, vec![1, 2], "remove: numbers are kept"); - assert_eq!(draft.slots()[0].name, "b.txt", "remove: the other card's name"); + assert_eq!( + draft.slots()[0].name, + "b.txt", + "remove: the other card's name" + ); // Case: add and remove clicks are told apart from a save. let add = form(&[("op", "add"), ("name_0", "a")]); @@ -922,7 +930,11 @@ mod tests { assert_eq!(draft.slots().len(), 2, "add click: two cards"); let remove = form(&[("remove", "1"), ("name_0", "a"), ("name_1", "")]); let mut draft = Draft::from_form(&remove); - assert_eq!(apply_slot_step(&mut draft, &remove), Some(0), "remove click: tab"); + assert_eq!( + apply_slot_step(&mut draft, &remove), + Some(0), + "remove click: tab" + ); assert_eq!(draft.slots().len(), 1, "remove click: one card"); assert_eq!( apply_slot_step(&mut Draft::blank(), &form(&[("title", "t")])), @@ -933,8 +945,16 @@ mod tests { // Case: add shows the new last file. let mut draft = Draft::blank(); let add = form(&[("op", "add"), ("name_0", "a")]); - assert_eq!(apply_slot_step(&mut draft, &add), Some(0), "add shows: first add"); - assert_eq!(apply_slot_step(&mut draft, &add), Some(1), "add shows: new last"); + assert_eq!( + apply_slot_step(&mut draft, &add), + Some(0), + "add shows: first add" + ); + assert_eq!( + apply_slot_step(&mut draft, &add), + Some(1), + "add shows: new last" + ); assert_eq!(draft.slots().len(), 2, "add shows: two cards"); // Case: removing a card shows the file before it, and the first one when it is first. @@ -944,10 +964,18 @@ mod tests { } // Files 0..=2 at positions 0..=2; removing the file at position 2 shows position 1. let remove = form(&[("remove", "2")]); - assert_eq!(apply_slot_step(&mut draft, &remove), Some(1), "remove shows: before"); + assert_eq!( + apply_slot_step(&mut draft, &remove), + Some(1), + "remove shows: before" + ); // Removing the first file shows the new first one. let remove = form(&[("remove", "0")]); - assert_eq!(apply_slot_step(&mut draft, &remove), Some(0), "remove shows: first"); + assert_eq!( + apply_slot_step(&mut draft, &remove), + Some(0), + "remove shows: first" + ); // Case: a failed save keeps the posted tab, and falls back to the first. let mut draft = Draft::blank(); @@ -956,8 +984,16 @@ mod tests { } let numbers: Vec = draft.slots().iter().map(|s| s.number).collect(); assert_eq!(numbers, vec![0, 1, 2], "failed save: three cards"); - assert_eq!(posted_tab(&draft, &form(&[("tab", "2")])), 2, "failed save: posted tab"); - assert_eq!(posted_tab(&draft, &form(&[("tab", "9")])), 0, "failed save: unknown tab"); + assert_eq!( + posted_tab(&draft, &form(&[("tab", "2")])), + 2, + "failed save: posted tab" + ); + assert_eq!( + posted_tab(&draft, &form(&[("tab", "9")])), + 0, + "failed save: unknown tab" + ); assert_eq!(posted_tab(&draft, &form(&[])), 0, "failed save: no tab"); } } diff --git a/crates/forge-web/src/pages/tree.rs b/crates/forge-web/src/pages/tree.rs index 13b54bb..9ad212e 100644 --- a/crates/forge-web/src/pages/tree.rs +++ b/crates/forge-web/src/pages/tree.rs @@ -422,7 +422,7 @@ pub async fn latest_commit_bar(bar: LatestBar, lang: Lang) -> Result (author) } - (last.summary) + commit_line(subject: last.summary.clone()) (short) @@ -572,7 +572,7 @@ async fn tree_page(cx: &Cx) -> Result { Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) -
    +
    ref_selector(lang: lang, label: mi::t(lang, MK::RefLabel), current: ref_name.clone(), branches: branches, tags: tags, diff --git a/crates/forge-web/src/pages/wiki.rs b/crates/forge-web/src/pages/wiki.rs index 2e95129..c2405a6 100644 --- a/crates/forge-web/src/pages/wiki.rs +++ b/crates/forge-web/src/pages/wiki.rs @@ -26,6 +26,7 @@ use crate::i18n::{self, Lang}; use crate::live::Topic; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, load_repo}; +use crate::pages::repo_settings::settings_frame; use crate::pages::wiki_live::{bump_wiki, page_live_url, wiki_live_url}; use crate::render::markdown::render_markdown; use crate::state::AppState; @@ -204,7 +205,7 @@ fn page_links( #[component] async fn wiki_view_body(html: String) -> Result { Ok(view! { -
    +
    (Unescaped::new_unchecked(html))
    }) @@ -219,7 +220,7 @@ async fn wiki_empty_body( ) -> Result { let new = repo_href(&owner, &repo, "wiki", "-/new"); Ok(view! { -
    +
    empty_state(title: g::t(lang, K::WikiNoPages), if can_write { (g::t(lang, K::CreateFirstPage)) @@ -244,7 +245,7 @@ async fn wiki_list_body( }) .collect(); Ok(view! { -
    +
    if rows.is_empty() { empty_state(title: g::t(lang, K::NoPagesYet)) } else { @@ -261,7 +262,7 @@ async fn wiki_list_body( #[component] async fn wiki_history_body(lang: Lang, rows: Vec) -> Result { Ok(view! { -
    +
    if rows.is_empty() { empty_state(title: g::t(lang, K::NoChangesYet)) } else { @@ -723,7 +724,9 @@ async fn wiki_settings_page(cx: &Cx) -> Result { Ok(view! { cx => shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) - wiki_settings_body(lang: lang, action: action, csrf: csrf, enabled: enabled) + settings_frame(lang: lang, title: format!("{}/{}", ctx.repo.owner_name, ctx.repo.name), current: "wiki", + wiki_settings_body(lang: lang, action: action, csrf: csrf, enabled: enabled) + ) ) }) } diff --git a/crates/forge-web/src/render/commit_message.rs b/crates/forge-web/src/render/commit_message.rs index d02ec5f..0cbe9da 100644 --- a/crates/forge-web/src/render/commit_message.rs +++ b/crates/forge-web/src/render/commit_message.rs @@ -150,7 +150,10 @@ fn strip_marker(clause: &str) -> &str { fn split_type(clause: &str) -> Option<(&'static str, &str)> { let rest = strip_marker(clause); let word_len = rest.bytes().take_while(u8::is_ascii_lowercase).count(); - let kind = KINDS.iter().copied().find(|kind| *kind == &rest[..word_len])?; + let kind = KINDS + .iter() + .copied() + .find(|kind| *kind == &rest[..word_len])?; let mut tail = &rest[word_len..]; if let Some(after) = tail.strip_prefix('(') { let close = after.find(')')?; diff --git a/crates/forge-web/src/repo_stats.rs b/crates/forge-web/src/repo_stats.rs index 69a3e1e..3594af3 100644 --- a/crates/forge-web/src/repo_stats.rs +++ b/crates/forge-web/src/repo_stats.rs @@ -109,7 +109,14 @@ const EXTENSIONS: &[(&str, &str)] = &[ ]; /// Directory names whose contents are vendored or built, so they never count. -const SKIPPED_SEGMENTS: &[&str] = &["vendor", "node_modules", "third_party", "dist", "target", ".git"]; +const SKIPPED_SEGMENTS: &[&str] = &[ + "vendor", + "node_modules", + "third_party", + "dist", + "target", + ".git", +]; /// The language a path counts as, by its exact file name or its extension. None for anything /// unknown, vendored, generated or prose. diff --git a/crates/forge-web/src/views/diff.rs b/crates/forge-web/src/views/diff.rs index a17a87a..9dc4e84 100644 --- a/crates/forge-web/src/views/diff.rs +++ b/crates/forge-web/src/views/diff.rs @@ -110,11 +110,7 @@ impl DiffOpts { let split = match current_user(cx).await? { Some((user, _)) => { let state = app_context::(cx); - let stored = state - .store - .user_prefs(&user.id) - .await? - .remove(DIFF_VIEW); + let stored = state.store.user_prefs(&user.id).await?.remove(DIFF_VIEW); match view_param.as_deref() { Some(v @ ("split" | "unified")) => { if stored.as_deref() != Some(v) { diff --git a/crates/forge-web/src/views/mod.rs b/crates/forge-web/src/views/mod.rs index dca932b..a86328d 100644 --- a/crates/forge-web/src/views/mod.rs +++ b/crates/forge-web/src/views/mod.rs @@ -32,11 +32,11 @@ use crate::i18n::authoring::{self as au, K as AuK}; use crate::i18n::browse as br; use crate::i18n::code::{self as g, K}; use crate::i18n::community::{self as cm, K as CK}; -use crate::i18n::packages::{self as pk, K as PK}; use crate::i18n::link::{self as lk, K as LinkKey}; use crate::i18n::migrate::{self as mg, K as MGK}; use crate::i18n::misc::{self as mi, K as MK}; use crate::i18n::orgs::{self as o, K as OK}; +use crate::i18n::packages::{self as pk, K as PK}; use crate::i18n::{self, Key, Lang, t}; use crate::pages::assets::highlight_css_text; use crate::pages::user_prefs::{CORNER_POS, TREE_WIDTH, clean_pref}; @@ -156,7 +156,9 @@ fn path_segments(path: &str, title: &str) -> Vec<(String, Option)> { if let Some(repo) = parts.get(1) { segments.push((repo.clone(), Some(repo_href(owner, repo, "", "")))); match &parts[2..] { - [kind, git_ref, prefix @ ..] if matches!(kind.as_str(), "tree" | "blob") && !prefix.is_empty() => { + [kind, git_ref, prefix @ ..] + if matches!(kind.as_str(), "tree" | "blob") && !prefix.is_empty() => + { let mut at = git_ref.clone(); for part in prefix { at.push('/'); @@ -206,7 +208,15 @@ fn live_strip(lang: Lang, runs: &ActorRuns) -> LiveStrip { let mut rows = Vec::new(); for run in &runs.running { let job = run.current_job.as_deref().unwrap_or(""); - rows.push(strip_run("hot", run, if job.is_empty() { String::new() } else { format!(" {job}") })); + rows.push(strip_run( + "hot", + run, + if job.is_empty() { + String::new() + } else { + format!(" {job}") + }, + )); } for run in &runs.finished { let (state, word) = match run.state { @@ -217,7 +227,9 @@ fn live_strip(lang: Lang, runs: &ActorRuns) -> LiveStrip { }; rows.push(strip_run(state, run, format!(" {word}"))); } - let count = |pred: fn(RunState) -> bool| runs.finished.iter().filter(|run| pred(run.state)).count() as u64; + let count = |pred: fn(RunState) -> bool| { + runs.finished.iter().filter(|run| pred(run.state)).count() as u64 + }; let running = runs.running.len() as u64; let failed = count(|state| matches!(state, RunState::Failure | RunState::Error)); let passed = count(|state| matches!(state, RunState::Success)); @@ -304,20 +316,43 @@ struct ProfileCorner { #[component] async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result { let review_chip = (corner.reviews > 0).then(|| { - (corner.reviews.to_string(), mi::review_requests_count(lang, corner.reviews)) + ( + corner.reviews.to_string(), + mi::review_requests_count(lang, corner.reviews), + ) + }); + let mention_chip = (corner.mentions > 0).then(|| { + ( + corner.mentions.to_string(), + mi::mentions_count(lang, corner.mentions), + ) + }); + let failing_chip = (corner.failing > 0).then(|| { + ( + corner.failing.to_string(), + mi::failing_runs_count(lang, corner.failing), + ) }); - let mention_chip = (corner.mentions > 0) - .then(|| (corner.mentions.to_string(), mi::mentions_count(lang, corner.mentions))); - let failing_chip = (corner.failing > 0) - .then(|| (corner.failing.to_string(), mi::failing_runs_count(lang, corner.failing))); let bell_label = mi::t(lang, MK::AllNotifications); let theme_label = mi::t(lang, MK::ThemeLabel); let match_label = mi::t(lang, MK::MatchSystem); let light_label = mi::t(lang, MK::Light); let dark_label = mi::t(lang, MK::Dark); - let auto_pressed = if corner.theme == "auto" { "true" } else { "false" }; - let light_pressed = if corner.theme == "light" { "true" } else { "false" }; - let dark_pressed = if corner.theme == "dark" { "true" } else { "false" }; + let auto_pressed = if corner.theme == "auto" { + "true" + } else { + "false" + }; + let light_pressed = if corner.theme == "light" { + "true" + } else { + "false" + }; + let dark_pressed = if corner.theme == "dark" { + "true" + } else { + "false" + }; // The chips' titles as nav.js rebuilds them: the server's phrase with `{n}` for the count. The // singular and plural forms are separate, as English puts "request" and "requests" apart. let review_template = count_template(&mi::review_requests_count(lang, 2), 2); @@ -464,6 +499,7 @@ pub async fn shell( None }; let section_menu = section.clone(); + let site_shell = section.as_ref().is_some_and(|s| s.site); let theme_attr = crate::theme::data_theme(__cx, viewer.map(|(user, _)| user)); // The relative-time wording and the server's clock, for nav.js to keep `
    } -
    +
    if let Some(section) = section {