From 3aaf5efc6e6aa5d8c495134443cad39e537ccf20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?=
Date: Sun, 1 Nov 2026 09:44:06 +0300
Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20four=20passes=20over=20?=
=?UTF-8?q?every=20page=20in=20both=20themes=20and=20on=20phones:=20all=20?=
=?UTF-8?q?menus,=20dropdowns=20and=20popovers=20share=20one=20panel=20and?=
=?UTF-8?q?=20open=20at=20once,=20selects,=20checkboxes,=20scrollbars=20an?=
=?UTF-8?q?d=20disclosure=20chevrons=20replace=20the=20browser's,=20labels?=
=?UTF-8?q?=20are=20tinted=20chips,=20one-pane=20settings=20and=20admin=20?=
=?UTF-8?q?pages=20use=20the=20full=20width,=20sessions=20are=20one=20row?=
=?UTF-8?q?=20each,=20the=20audit=20filter=20sits=20above=20its=20table,?=
=?UTF-8?q?=20Create=20and=20Import=20share=20the=20page=20head,=20Compare?=
=?UTF-8?q?=20is=20one=20row,=20a=20folder=20with=20no=20README=20gives=20?=
=?UTF-8?q?its=20list=20the=20width,=20and=20new=20pages'=20empty=20states?=
=?UTF-8?q?=20lose=20buttons=20that=20repeat=20the=20form=20beside=20them;?=
=?UTF-8?q?=20=E2=9A=A1=20perf:=20a=20run=20page=20embeds=2024=20KiB=20of?=
=?UTF-8?q?=20log=20rather=20than=20512,=20with=20a=20link=20to=20the=20fu?=
=?UTF-8?q?ll=20log,=20and=20links=20prefetch=20on=20press,=20so=20opening?=
=?UTF-8?q?=20CI=20is=20as=20quick=20as=20Issues;=20=E2=9C=A8=20feat:=20ru?=
=?UTF-8?q?n=20tones=20are=20told=20apart=20at=20once,=20a=20bright=20risi?=
=?UTF-8?q?ng=20chime=20for=20passed=20and=20a=20low=20double=20buzz=20for?=
=?UTF-8?q?=20failed;=20=F0=9F=94=A5=20remove:=20the=20density=20setting,?=
=?UTF-8?q?=20which=20changed=20nothing=20on=20the=20pages=20people=20use;?=
=?UTF-8?q?=20the=20settings=20side=20switch=20says=20what=20it=20moves;?=
=?UTF-8?q?=20=F0=9F=90=9B=20fix:=20file=20tree=20icons=20are=20no=20longe?=
=?UTF-8?q?r=20black=20on=20dark,=20the=20site=20banner=20lines=20up=20wit?=
=?UTF-8?q?h=20the=20page,=20the=20pulls=20page=20no=20longer=20scrolls=20?=
=?UTF-8?q?sideways=20on=20a=20phone,=20phone=20tables=20keep=20two=20stra?=
=?UTF-8?q?ight=20columns,=20blame=20stays=20readable=20in=20both=20themes?=
=?UTF-8?q?,=20and=20syntax=20colours=20reach=204.5:1=20in=20light;=20a=20?=
=?UTF-8?q?run=20whose=20commit=20was=20overwritten=20cannot=20be=20re-run?=
=?UTF-8?q?,=20standbys=20prune=20too,=20links=20to=20pruned=20commits=20n?=
=?UTF-8?q?o=20longer=20dangle,=20and=20a=20contribution=20or=20a=20stored?=
=?UTF-8?q?=20run=20no=20longer=20shows=20a=20commit=20that=20is=20gone?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crates/forge-core/src/store/contributions.rs | 24 +
crates/forge-core/src/store/user_prefs.rs | 16 +-
crates/forge-git/src/browse.rs | 44 +-
crates/forge-git/src/maintenance.rs | 15 +
crates/forge-web/assets/nav.js | 86 ++-
crates/forge-web/src/i18n/misc.rs | 38 +-
crates/forge-web/src/i18n/mod.rs | 4 +-
crates/forge-web/src/i18n/releases_ci.rs | 10 +
crates/forge-web/src/i18n/repo_admin.rs | 4 +-
crates/forge-web/src/pages/ci_job.rs | 21 +-
crates/forge-web/src/pages/ci_runs.rs | 86 ++-
crates/forge-web/src/pages/ci_tests.rs | 46 +-
crates/forge-web/src/pages/compare.rs | 10 +-
crates/forge-web/src/pages/discussion_view.rs | 4 +-
crates/forge-web/src/pages/import.rs | 12 +-
crates/forge-web/src/pages/issue_parts.rs | 46 +-
crates/forge-web/src/pages/issue_view.rs | 4 +-
crates/forge-web/src/pages/issues_list.rs | 4 +-
crates/forge-web/src/pages/labels_css.rs | 55 +-
crates/forge-web/src/pages/new_repo.rs | 2 +-
crates/forge-web/src/pages/notifications.rs | 2 +-
crates/forge-web/src/pages/pull_view.rs | 19 +-
crates/forge-web/src/pages/repo_webhooks.rs | 5 +-
crates/forge-web/src/pages/review_requests.rs | 4 +-
.../src/pages/settings_appearance.rs | 59 +-
crates/forge-web/src/prune.rs | 52 +-
crates/forge-web/src/render/highlight.rs | 70 +-
crates/forge-web/src/replication/worker.rs | 42 ++
crates/forge-web/src/views/heatmap.rs | 40 +-
crates/forge-web/src/views/mod.rs | 3 +-
crates/forge-web/src/views/review_thread.rs | 2 +-
docs/architecture.md | 2 +
docs/backup.md | 4 +
style/_account_admin.scss | 3 +-
style/{_density.scss => _appearance.scss} | 42 --
style/_canvas_account.scss | 2 +-
style/_canvas_pull.scss | 2 +-
style/_canvas_repo.scss | 25 +-
style/_heatmap.scss | 1 -
style/_kb_rerun.scss | 10 +-
style/_lang_issues.scss | 4 +-
style/_language.scss | 3 +-
style/_motion.scss | 28 -
style/_needs.scss | 2 +-
style/_pull.scss | 6 +-
style/_repo.scss | 4 -
style/_shell.scss | 2 -
style/_system.scss | 653 ++++++++++++++++++
style/_timeline_ci.scss | 3 +-
style/main.scss | 40 +-
50 files changed, 1267 insertions(+), 398 deletions(-)
rename style/{_density.scss => _appearance.scss} (68%)
create mode 100644 style/_system.scss
diff --git a/crates/forge-core/src/store/contributions.rs b/crates/forge-core/src/store/contributions.rs
index f805b01..4ccde3e 100644
--- a/crates/forge-core/src/store/contributions.rs
+++ b/crates/forge-core/src/store/contributions.rs
@@ -197,6 +197,30 @@ impl Store {
.map_err(db_err)?;
Ok(())
}
+
+ /// The distinct commit ids in `repo_id` whose stored message is not blank.
+ pub async fn coauthored_oids(&self, repo_id: &str) -> Result> {
+ let sql = "SELECT DISTINCT commit_oid FROM coauthored_commits \
+ WHERE repo_id = ?1 AND summary <> '' ORDER BY commit_oid";
+ let params = vec![Value::Text(repo_id.to_string())];
+ let conn = self.read_conn().await;
+ fetch_all(&conn, sql, params, |row| col_text(row, 0)).await
+ }
+
+ /// Blanks the stored message of the commits `oids` in `repo_id`, for every user. The rows stay,
+ /// so contribution counts do not change.
+ pub async fn blank_coauthored(&self, repo_id: &str, oids: &[String]) -> Result<()> {
+ let conn = self.inner.conn.lock().await;
+ for oid in oids {
+ conn.execute(
+ "UPDATE coauthored_commits SET summary = '' WHERE repo_id = ?1 AND commit_oid = ?2",
+ (repo_id.to_string(), oid.clone()),
+ )
+ .await
+ .map_err(db_err)?;
+ }
+ Ok(())
+ }
}
#[cfg(test)]
diff --git a/crates/forge-core/src/store/user_prefs.rs b/crates/forge-core/src/store/user_prefs.rs
index 105f2eb..5f5a0f8 100644
--- a/crates/forge-core/src/store/user_prefs.rs
+++ b/crates/forge-core/src/store/user_prefs.rs
@@ -8,10 +8,6 @@ use super::{Store, col_text, db_err, fetch_all};
use crate::error::Result;
use crate::time::now_stamp;
-/// Key of the row density: `comfortable` (the default, no row) or `compact`.
-pub const DENSITY: &str = "density";
-/// The densities a user may store.
-pub const DENSITIES: &[&str] = &["comfortable", "compact"];
/// Key of the run-finished tone: `on` or `off` (the default, no row).
pub const SOUND: &str = "sound";
/// The sound values a user may store.
@@ -69,7 +65,7 @@ mod tests {
use crate::store::Store;
#[tokio::test]
- async fn density_and_sound_round_trip_and_replace() {
+ async fn a_pref_round_trips_and_replaces() {
let dir = tempfile::tempdir().unwrap();
let store = Store::open(&dir.path().join("forge.db")).await.unwrap();
let user = store
@@ -78,18 +74,10 @@ mod tests {
.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, SOUND, "off").await.unwrap();
store.set_user_pref(&user.id, SOUND, "on").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"));
assert_eq!(prefs.get(SOUND).map(String::as_str), Some("on"));
}
}
diff --git a/crates/forge-git/src/browse.rs b/crates/forge-git/src/browse.rs
index 9d8b12b..fad5f7a 100644
--- a/crates/forge-git/src/browse.rs
+++ b/crates/forge-git/src/browse.rs
@@ -3,6 +3,7 @@
//! Everything here is blocking; callers run it inside `spawn_blocking`. Repositories are opened
//! isolated: the environment and user/system git configuration are ignored.
+use std::collections::HashSet;
use std::path::Path;
use gix::bstr::ByteSlice;
@@ -226,26 +227,31 @@ fn resolve_hex(repo: &gix::Repository, hex: &str) -> Result> {
/// The refs whose history is public. A commit no ref here reaches was overwritten or deleted.
const VISIBLE_REFS: [&str; 3] = ["refs/heads/", "refs/tags/", "refs/pull/"];
-/// True when a branch, tag or pull request reaches `id`. Other commits stay on disk until
-/// `maintenance::prune_unreachable` runs, and must not be served by hash until then.
-fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result {
+/// The commits at the tips of [`VISIBLE_REFS`]. A ref that does not peel to a commit reaches nothing.
+fn visible_tips(repo: &gix::Repository) -> Result> {
let refs = repo.references().map_err(gerr)?;
let mut tips = Vec::new();
for prefix in VISIBLE_REFS {
for reference in refs.prefixed(prefix).map_err(gerr)? {
let mut reference = reference.map_err(gerr)?;
- // A ref that does not peel to a commit reaches nothing.
if let Ok(tip) = reference.peel_to_id() {
let tip = tip.detach();
- if tip == id {
- return Ok(true);
- }
if is_commit(repo, tip)? {
tips.push(tip);
}
}
}
}
+ Ok(tips)
+}
+
+/// True when a branch, tag or pull request reaches `id`. Other commits stay on disk until
+/// `maintenance::prune_unreachable` runs, and must not be served by hash until then.
+fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result {
+ let tips = visible_tips(repo)?;
+ if tips.contains(&id) {
+ return Ok(true);
+ }
if tips.is_empty() {
return Ok(false);
}
@@ -257,6 +263,30 @@ fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result {
Ok(false)
}
+/// Those of the full commit ids `oids` that a branch, tag or pull request reaches, in one walk.
+/// Malformed ids are left out. For deciding which stored hashes on a page may still link.
+pub fn reachable_commits(repo: &Path, oids: &[String]) -> Result> {
+ let mut wanted: HashSet =
+ oids.iter().filter_map(|oid| parse_oid(oid).ok()).collect();
+ let repo = open(repo)?;
+ let mut found = HashSet::new();
+ wanted.retain(|id| matches!(repo.try_find_header(*id), Ok(Some(_))));
+ let tips = visible_tips(&repo)?;
+ if wanted.is_empty() || tips.is_empty() {
+ return Ok(found);
+ }
+ for info in repo.rev_walk(tips).all().map_err(gerr)? {
+ let id = info.map_err(gerr)?.id;
+ if wanted.remove(&id) {
+ found.insert(id.to_hex().to_string());
+ if wanted.is_empty() {
+ break;
+ }
+ }
+ }
+ Ok(found)
+}
+
/// True when `oid` is a full commit id that a branch, tag or pull request reaches.
pub fn commit_reachable(repo: &Path, oid: &str) -> Result {
let repo = open(repo)?;
diff --git a/crates/forge-git/src/maintenance.rs b/crates/forge-git/src/maintenance.rs
index 15d7359..0f7ecb4 100644
--- a/crates/forge-git/src/maintenance.rs
+++ b/crates/forge-git/src/maintenance.rs
@@ -16,6 +16,9 @@ const PRUNE_TIMEOUT: Duration = Duration::from_secs(30 * 60);
const PRUNE_MARK: &str = "forge-prune-due";
/// Touched after each prune.
const PRUNE_STAMP: &str = "forge-pruned";
+/// Written after a prune removed objects. The standby still holds them, so its next replication
+/// prunes its copy and clears this mark.
+const STANDBY_PRUNE_MARK: &str = "forge-standby-prune-due";
/// A push's objects are unreachable for a moment before its ref lands, so only objects at least
/// this old are removed. The mark waits this long too, so everything it stands for qualifies.
const PRUNE_GRACE: Duration = Duration::from_secs(15 * 60);
@@ -79,6 +82,7 @@ pub async fn prune_unreachable(env: &GitEnv, repo: &Path, prune: &'static str) -
}
}
fs::write(repo.join(PRUNE_STAMP), b"")?;
+ fs::write(repo.join(STANDBY_PRUNE_MARK), b"")?;
// A mark written during the prune stays for the next pass.
if let Ok(marked) = marked
&& fs::metadata(repo.join(PRUNE_MARK))
@@ -91,6 +95,17 @@ pub async fn prune_unreachable(env: &GitEnv, repo: &Path, prune: &'static str) -
Ok(())
}
+/// True when a prune removed objects that the standby copy of `repo` still holds.
+pub fn standby_prune_due(repo: &Path) -> bool {
+ repo.join(STANDBY_PRUNE_MARK).is_file()
+}
+
+/// Clears the standby mark once the standby has been pruned. Best effort: a mark left behind only
+/// causes one more harmless prune.
+pub fn clear_standby_prune(repo: &Path) {
+ let _ = fs::remove_file(repo.join(STANDBY_PRUNE_MARK));
+}
+
/// Runs `cmd` with [`STEP_TIMEOUT`]. Dropping the future on timeout drops the child,
/// which `GitCommand` spawns with `kill_on_drop`, so the process is killed.
async fn run_bounded(cmd: GitCommand) -> Result<()> {
diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js
index 41735be..104d341 100644
--- a/crates/forge-web/assets/nav.js
+++ b/crates/forge-web/assets/nav.js
@@ -2511,28 +2511,59 @@
var finishedKeys = null; // the runs the newest answer listed; null until the first one
var toneCtx = null; // the AudioContext, made on first use
- // The two notes of an outcome: rising C5 then G5 for a pass, falling for a failure. Each note is a
- // short sine with a quick fade in and out, so nothing clicks.
+ // The two outcomes differ in everything an ear uses, so neither is a guess. A pass is high, clean
+ // and quick: a rising C major chime that rings out. A failure is low, rough and heavy: two falling
+ // buzzes, each a pair of notes a semitone apart that beat against each other.
+ var TONES = {
+ passed: {
+ wave: 'triangle', peak: 0.16, cutoff: 8000,
+ notes: [
+ { at: 0, hz: [523.25], len: 0.16 },
+ { at: 0.09, hz: [659.25], len: 0.16 },
+ { at: 0.18, hz: [783.99, 1046.5], len: 0.5 }
+ ]
+ },
+ failed: {
+ wave: 'sawtooth', peak: 0.2, cutoff: 900,
+ notes: [
+ { at: 0, hz: [196, 207.65], len: 0.24 },
+ { at: 0.26, hz: [146.83, 155.56], len: 0.46 }
+ ]
+ }
+ };
+
+ // Schedules an outcome's notes on `ctx`, fading each in and out so nothing clicks.
+ function scheduleTones(ctx, outcome) {
+ var tone = TONES[outcome] || TONES.failed;
+ var filter = ctx.createBiquadFilter();
+ filter.type = 'lowpass';
+ filter.frequency.value = tone.cutoff;
+ filter.connect(ctx.destination);
+ var start = ctx.currentTime + 0.02;
+ tone.notes.forEach(function (note) {
+ var at = start + note.at;
+ var gain = ctx.createGain();
+ gain.gain.setValueAtTime(0.0001, at);
+ gain.gain.exponentialRampToValueAtTime(tone.peak, at + 0.012);
+ gain.gain.exponentialRampToValueAtTime(0.0001, at + note.len);
+ gain.connect(filter);
+ note.hz.forEach(function (hz) {
+ var osc = ctx.createOscillator();
+ osc.type = tone.wave;
+ osc.frequency.value = hz;
+ osc.connect(gain);
+ osc.start(at);
+ osc.stop(at + note.len + 0.02);
+ });
+ });
+ }
+
function playTones(outcome) {
var AC = window.AudioContext || window.webkitAudioContext;
if (!AC) { return; }
try { toneCtx = toneCtx || new AC(); } catch (err) { return; }
if (toneCtx.state === 'suspended') { toneCtx.resume().catch(function () { }); }
- var freqs = outcome === 'passed' ? [523.25, 783.99] : [783.99, 523.25];
- var start = toneCtx.currentTime + 0.02;
- freqs.forEach(function (hz, i) {
- var at = start + i * 0.14;
- var osc = toneCtx.createOscillator(), gain = toneCtx.createGain();
- osc.type = 'sine';
- osc.frequency.value = hz;
- gain.gain.setValueAtTime(0.0001, at);
- gain.gain.exponentialRampToValueAtTime(0.15, at + 0.02);
- gain.gain.exponentialRampToValueAtTime(0.0001, at + 0.16);
- osc.connect(gain);
- gain.connect(toneCtx.destination);
- osc.start(at);
- osc.stop(at + 0.18);
- });
+ scheduleTones(toneCtx, outcome);
}
// One tab plays for a run. Each tab writes its id under the run's key when the key is free, waits
@@ -2585,12 +2616,6 @@
if (b) { playTones(b.getAttribute('data-sound-play')); }
});
- // Signed-out visitors keep their density in localStorage. Signed in, the shell has set
- // `data-density` on already, so nothing is read here.
- if (!signedIn && !root.hasAttribute('data-density')) {
- try { if (localStorage.getItem('forge-density') === 'compact') { root.setAttribute('data-density', 'compact'); } } catch (err) { }
- }
-
// The CI log (a job page's [data-live-log]). The server sends the raw text; this turns it into
// numbered lines (#L12 anchors) with ANSI colours as spans, `::group::name` / `::endgroup::`
// sections as , and a search box with highlight and next/previous. Streamed bytes go
@@ -3566,7 +3591,7 @@
// Hover prefetch: a link the pointer rests on for a moment starts its page request early, so the
// click that often follows finds the answer already on its way. Only what the click handler would
// soft-navigate is fetched, and never a path that writes when viewed or serves a file.
- var PREFETCH_DELAY = 80; // ms the pointer must rest on a link before its request starts
+ var PREFETCH_DELAY = 30; // ms the pointer must rest on a link before its request starts
var PREFETCH_TTL = 10000; // ms a finished or running prefetch is still used by a click
var PREFETCH_MAX = 4; // stored prefetches; the oldest is dropped first
var NO_PREFETCH = /\/-\/|\/(live|events|stream|open|download)$|\/(archive|raw|actions|attachments|artifacts)\/|\.zip$|\.tar\.gz$|\/releases\/download\/|^\/(logout|notifications)(\/|$)/;
@@ -3633,6 +3658,19 @@
}, PREFETCH_DELAY);
}, true);
+ // A press means the click is coming: the request leaves now, not when the button comes back up.
+ document.addEventListener('pointerdown', function (e) {
+ var a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
+ var url = a && e.button === 0 ? prefetchUrl(a) : null;
+ if (!url || !prefetchAllowed()) { return; }
+ for (var i = 0; i < prefetches.length; i++) {
+ if (prefetches[i].key === url.href) { return; }
+ }
+ clearTimeout(prefetchTimer);
+ prefetchTimer = null;
+ startPrefetch(url);
+ }, true);
+
// Leaving the link (not moving between its children) cancels a prefetch that has not started yet.
document.addEventListener('mouseout', function (e) {
var a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs
index 2651174..ffcd012 100644
--- a/crates/forge-web/src/i18n/misc.rs
+++ b/crates/forge-web/src/i18n/misc.rs
@@ -42,12 +42,7 @@ pub enum K {
SidebarLeft,
SidebarRight,
ChooseSidebar,
- // Appearance: row density, and the run-finished tone.
- DensityLabel,
- DensityComfortable,
- DensityCompact,
- DensityHelp,
- ChooseDensity,
+ // Appearance: the run-finished tone.
SoundLabel,
SoundSwitch,
SoundOwnRuns,
@@ -57,7 +52,6 @@ pub enum K {
SoundFailedNote,
SoundPlay,
SoundFootOwn,
- SoundFootTones,
ChooseSound,
// Notifications: row kinds.
KindOpenIssue,
@@ -228,11 +222,6 @@ const ALL: &[K] = &[
K::SidebarLeft,
K::SidebarRight,
K::ChooseSidebar,
- K::DensityLabel,
- K::DensityComfortable,
- K::DensityCompact,
- K::DensityHelp,
- K::ChooseDensity,
K::SoundLabel,
K::SoundSwitch,
K::SoundOwnRuns,
@@ -242,7 +231,6 @@ const ALL: &[K] = &[
K::SoundFailedNote,
K::SoundPlay,
K::SoundFootOwn,
- K::SoundFootTones,
K::ChooseSound,
K::KindOpenIssue,
K::KindClosedIssue,
@@ -424,24 +412,14 @@ pub fn t(lang: Lang, key: K) -> &'static str {
(BackgroundLabel, Tr) => "Arka plan",
(ChooseBase, En) => "Choose a background from the list.",
(ChooseBase, Tr) => "Listeden bir arka plan seçin.",
- (SidebarLabel, En) => "Sidebar position",
- (SidebarLabel, Tr) => "Kenar çubuğu konumu",
+ (SidebarLabel, En) => "Settings menu side",
+ (SidebarLabel, Tr) => "Ayarlar menüsünün yanı",
(SidebarLeft, En) => "Left",
(SidebarLeft, Tr) => "Sol",
(SidebarRight, En) => "Right",
(SidebarRight, Tr) => "Sağ",
(ChooseSidebar, En) => "Choose a sidebar position from the list.",
(ChooseSidebar, Tr) => "Listeden bir kenar çubuğu konumu seçin.",
- (DensityLabel, En) => "Density",
- (DensityLabel, Tr) => "Yoğunluk",
- (DensityComfortable, En) => "Comfortable",
- (DensityComfortable, Tr) => "Rahat",
- (DensityCompact, En) => "Compact",
- (DensityCompact, Tr) => "Sıkı",
- (DensityHelp, En) => "Saved to your account. Compact shows more rows on a screen.",
- (DensityHelp, Tr) => "Hesabınıza kaydedilir. Sıkı görünüm ekranda daha çok satır gösterir.",
- (ChooseDensity, En) => "Choose Comfortable or Compact.",
- (ChooseDensity, Tr) => "Rahat ya da Sıkı seçin.",
(SoundLabel, En) => "Sound",
(SoundLabel, Tr) => "Ses",
(SoundSwitch, En) => "Play a tone when my run finishes",
@@ -450,18 +428,16 @@ pub fn t(lang: Lang, key: K) -> &'static str {
(SoundOwnRuns, Tr) => "Yalnızca kendi çalıştırmalarınız",
(SoundPassed, En) => "Run passed",
(SoundPassed, Tr) => "Çalıştırma başarılı",
- (SoundPassedNote, En) => "two rising notes",
- (SoundPassedNote, Tr) => "yükselen iki nota",
+ (SoundPassedNote, En) => "a bright rising chime",
+ (SoundPassedNote, Tr) => "parlak, yükselen bir çan",
(SoundFailed, En) => "Run failed",
(SoundFailed, Tr) => "Çalıştırma başarısız",
- (SoundFailedNote, En) => "two falling notes",
- (SoundFailedNote, Tr) => "alçalan iki nota",
+ (SoundFailedNote, En) => "a low, rough double buzz",
+ (SoundFailedNote, Tr) => "pes ve sert, çift vızıltı",
(SoundPlay, En) => "Play",
(SoundPlay, Tr) => "Çal",
(SoundFootOwn, En) => "Never for a page you are looking at.",
(SoundFootOwn, Tr) => "Baktığınız sayfa için asla çalmaz.",
- (SoundFootTones, En) => "Tones are made in the browser, with no audio files.",
- (SoundFootTones, Tr) => "Sesler tarayıcıda üretilir, ses dosyası yoktur.",
(ChooseSound, En) => "Choose on or off.",
(ChooseSound, Tr) => "Açık ya da kapalı seçin.",
(KindOpenIssue, En) => "Open issue",
diff --git a/crates/forge-web/src/i18n/mod.rs b/crates/forge-web/src/i18n/mod.rs
index 0646089..809b27f 100644
--- a/crates/forge-web/src/i18n/mod.rs
+++ b/crates/forge-web/src/i18n/mod.rs
@@ -1054,7 +1054,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
(MailReasonComment, En) => "you commented on it",
(MailReasonSubscribed, En) => "you are subscribed to it",
(MailReasonWatching, En) => "you watch this repository",
- (MenuNotificationEmails, En) => "Notification emails",
+ (MenuNotificationEmails, En) => "Notifications",
(EmailNotifyLabel, En) => "Email me about notifications",
(EmailNotifyHelp, En) => {
"Each notification is sent to your verified address. Notifications on the site are not affected."
@@ -1083,7 +1083,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
(MailReasonComment, Tr) => "bunda yorum yaptınız",
(MailReasonSubscribed, Tr) => "bunu takip ediyorsunuz",
(MailReasonWatching, Tr) => "bu depoyu izliyorsunuz",
- (MenuNotificationEmails, Tr) => "Bildirim e-postaları",
+ (MenuNotificationEmails, Tr) => "Bildirimler",
(EmailNotifyLabel, Tr) => "Bildirimler hakkında bana e-posta gönder",
(EmailNotifyHelp, Tr) => {
"Her bildirim doğrulanmış adresinize gönderilir. Sitedeki bildirimler bundan etkilenmez."
diff --git a/crates/forge-web/src/i18n/releases_ci.rs b/crates/forge-web/src/i18n/releases_ci.rs
index af364d5..f43c9cd 100644
--- a/crates/forge-web/src/i18n/releases_ci.rs
+++ b/crates/forge-web/src/i18n/releases_ci.rs
@@ -38,6 +38,8 @@ pub enum K {
CiNoticeNoFailed,
CiNoticeNotDone,
CiNoticeTooBig,
+ CiNoticeOverwritten,
+ CiCommitOverwritten,
LogSearch,
LogPrev,
LogNext,
@@ -232,6 +234,12 @@ pub fn t(lang: Lang, key: K) -> &'static str {
(CiNoticeTooBig, Tr) => {
"Yapıtlar tek dosya olarak indirilemeyecek kadar büyük. Tek tek indirin."
}
+ (CiNoticeOverwritten, En) => "This commit was overwritten, so it can't be re-run.",
+ (CiNoticeOverwritten, Tr) => {
+ "Bu commit'in üzerine yazıldı, bu yüzden yeniden çalıştırılamaz."
+ }
+ (CiCommitOverwritten, En) => "This commit was overwritten by a force push.",
+ (CiCommitOverwritten, Tr) => "Bu commit'in üzerine yazıldı.",
(LogSearch, En) => "Search the log",
(LogSearch, Tr) => "Günlükte ara",
(LogPrev, En) => "Previous match",
@@ -624,6 +632,8 @@ mod tests {
K::CiNoticeNoFailed,
K::CiNoticeNotDone,
K::CiNoticeTooBig,
+ K::CiNoticeOverwritten,
+ K::CiCommitOverwritten,
K::LogSearch,
K::LogPrev,
K::LogNext,
diff --git a/crates/forge-web/src/i18n/repo_admin.rs b/crates/forge-web/src/i18n/repo_admin.rs
index 8f3e982..d0f7e13 100644
--- a/crates/forge-web/src/i18n/repo_admin.rs
+++ b/crates/forge-web/src/i18n/repo_admin.rs
@@ -339,8 +339,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
}
(NewRule, Tr) => "Yeni kural",
(NoBranchesYet, Tr) => "Henüz dal yok. Varsayılan dal, ilk gönderimden sonra seçilebilir.",
- (NoCollaborators, En) => "No collaborators yet. Add one below.",
- (NoCollaborators, Tr) => "Henüz ortak çalışan yok. Aşağıdan bir ortak çalışan ekleyin.",
+ (NoCollaborators, En) => "No collaborators yet.",
+ (NoCollaborators, Tr) => "Henüz ortak çalışan yok.",
(NoPendingTransfer, En) => "No transfer is pending for this repository.",
(NoPendingTransfer, Tr) => "Bu depo için bekleyen bir devir yok.",
(NoSecrets, En) => "No secrets yet.",
diff --git a/crates/forge-web/src/pages/ci_job.rs b/crates/forge-web/src/pages/ci_job.rs
index 7527ef7..b0d033f 100644
--- a/crates/forge-web/src/pages/ci_job.rs
+++ b/crates/forge-web/src/pages/ci_job.rs
@@ -35,8 +35,8 @@ use crate::i18n::{
releases_ci::{self as g, K},
};
use crate::pages::ci_runs::{
- age_text, can_write, changed_event, dock_bars, duration_text, events_response, job_href,
- run_href, state_text, strip_ansi,
+ age_text, can_write, changed_event, commit_reachable_for, dock_bars, duration_text,
+ events_response, job_href, run_href, state_text, strip_ansi,
};
use crate::pages::repo::repo_head;
use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable};
@@ -145,6 +145,11 @@ async fn newlines_before(path: &Path, end: u64) -> Result {
/// The last `TAIL_BYTES` of a log, from a line boundary. A log that does not exist yet is empty.
pub(crate) async fn log_tail(path: &Path) -> Result {
+ log_tail_of(path, TAIL_BYTES).await
+}
+
+/// The last `max` bytes of a log, from a line boundary.
+pub(crate) async fn log_tail_of(path: &Path, max: u64) -> Result {
let mut file = match tokio::fs::File::open(path).await {
Ok(file) => file,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
@@ -158,17 +163,17 @@ pub(crate) async fn log_tail(path: &Path) -> Result {
Err(e) => return Err(forge_core::Error::Io(e).into()),
};
let len = file.metadata().await.map_err(forge_core::Error::Io)?.len();
- let truncated = len > TAIL_BYTES;
+ let truncated = len > max;
let mut start = 0;
if truncated {
- start = len - TAIL_BYTES;
+ start = len - max;
file.seek(SeekFrom::Start(start))
.await
.map_err(forge_core::Error::Io)?;
}
let mut buf = Vec::new();
(&mut file)
- .take(TAIL_BYTES)
+ .take(max)
.read_to_end(&mut buf)
.await
.map_err(forge_core::Error::Io)?;
@@ -515,6 +520,10 @@ async fn job_page(cx: &Cx) -> Result {
};
let title = title_of(&ctx);
let live = format!("{}/events", job_href(&title, &job.id));
+ // A job of a run whose commit was overwritten cannot be run again. The walk runs only for a writer.
+ let reachable = can_write(&ctx)
+ && job.state.is_terminal()
+ && commit_reachable_for(&ctx.path, &run.commit_oid).await?;
let view = JobView {
name: job.name.clone(),
fingerprint,
@@ -543,7 +552,7 @@ async fn job_page(cx: &Cx) -> Result {
run_href: run_href(&title, run.number),
run_number: run.number,
log_href: format!("{}/log.txt", job_href(&title, &job.id)),
- rerun: if job.state.is_terminal() && can_write(&ctx) {
+ rerun: if reachable {
ctx.viewer.as_ref().map(|(_, session)| {
(
format!("{}/rerun", job_href(&title, &job.id)),
diff --git a/crates/forge-web/src/pages/ci_runs.rs b/crates/forge-web/src/pages/ci_runs.rs
index 3a771b5..5fc27d6 100644
--- a/crates/forge-web/src/pages/ci_runs.rs
+++ b/crates/forge-web/src/pages/ci_runs.rs
@@ -8,14 +8,14 @@
//! `/{owner}/{repo}/ci/events`, which fires on every run created or changed in the repo, and a run or job
//! page opens its own `changed` stream (`.../events`) when it is not finished.
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use std::future::Future;
use std::path::Path;
use std::time::Duration;
use forge_core::ci::{CiJob, CiRun, JobSample, JobState, RunState};
use forge_core::{Action, Denied, Store, User, authorize};
-use forge_git::browse::{RefInfo, RefKind, read_commit};
+use forge_git::browse::{RefInfo, RefKind, commit_reachable, reachable_commits, read_commit};
use futures_util::{Stream, StreamExt, stream};
use serde::Deserialize;
use time::OffsetDateTime;
@@ -41,7 +41,7 @@ use crate::i18n::{
};
use crate::pages::ci_estimate::{self, Est, Step};
use crate::pages::ci_fail::{self, FailFirst, fail_first_block};
-use crate::pages::ci_job::{Tail, log_tail};
+use crate::pages::ci_job::{Tail, log_tail_of};
use crate::pages::refs::load_refs;
use crate::pages::repo::repo_head;
use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable};
@@ -64,7 +64,8 @@ const PER_PAGE: u32 = 25;
const MAX_PAGE: u32 = 1000;
/// Notice words (the only text a `?notice=` query can show), their text and whether they are errors.
-const NOTICES: [(&str, K, bool); 11] = [
+const NOTICES: [(&str, K, bool); 12] = [
+ ("overwritten", K::CiNoticeOverwritten, true),
("started", K::CiNoticeStarted, false),
("cancelled", K::CiNoticeCancelled, false),
("approved", K::CiNoticeApproved, false),
@@ -437,7 +438,10 @@ struct RunDetail {
state_class: String,
trigger: String,
branch: String,
- commit_href: String,
+ /// The commit's page. None when a force push overwrote the commit.
+ commit_href: Option,
+ /// Whether a branch, tag or pull request still reaches the commit. Re-run is offered only then.
+ reachable: bool,
commit: String,
actor: String,
/// The run's creation as an age, and its stamp for the `` that carries it.
@@ -701,6 +705,9 @@ const AXIS_STEPS: [i64; 14] = [
];
/// How far back from the end of a log the run page reads for its last lines.
const LOG_TAIL_BYTES: u64 = 16 * 1024;
+/// How much of the selected job's log the run page carries: the page has to open at once. The job
+/// page and the raw log hold the rest.
+const RUN_LOG_BYTES: u64 = 24 * 1024;
/// Lines of a log an expanded job row shows.
const LOG_LINES: usize = 20;
@@ -1377,13 +1384,20 @@ async fn runs_split(cx: &Cx, number: Option<&str>, job: Option<&str>) -> Result<
.map(|run| run.actor_id.as_str()),
)
.await?;
- // Commit subjects are the run titles. A commit that cannot be read leaves the trigger as the title.
- let path = ctx.path.clone();
let oids: Vec = runs
.iter()
.chain(selected.iter())
.map(|run| run.commit_oid.clone())
.collect();
+ // The commits a branch, tag or pull request still reaches. The others were overwritten: their runs
+ // show no link and cannot be run again. One walk covers the page.
+ let reachable: HashSet = {
+ let path = ctx.path.clone();
+ let oids = oids.clone();
+ tokio::task::spawn_blocking(move || reachable_commits(&path, &oids)).await??
+ };
+ // Commit subjects are the run titles. A commit that cannot be read leaves the trigger as the title.
+ let path = ctx.path.clone();
let subjects: HashMap = tokio::task::spawn_blocking(move || {
oids.into_iter()
.filter_map(|oid| {
@@ -1483,10 +1497,12 @@ async fn runs_split(cx: &Cx, number: Option<&str>, job: Option<&str>) -> Result<
String::new()
},
est,
- // The same condition as the run page's Re-run button: a writer, and a finished run.
+ // The same condition as the run page's Re-run button: a writer, a finished run and a
+ // commit that is still reachable.
rerun: csrf
.as_ref()
.filter(|_| run_finished(&run.state))
+ .filter(|_| reachable.contains(&run.commit_oid))
.map(|token| {
(
format!("{}/rerun", run_href(&title, run.number)),
@@ -1527,6 +1543,7 @@ async fn runs_split(cx: &Cx, number: Option<&str>, job: Option<&str>) -> Result<
title: subject,
actor,
writer_csrf: csrf.clone(),
+ reachable: reachable.contains(&run.commit_oid),
},
&runners,
lang,
@@ -1580,6 +1597,15 @@ struct RunHeader {
title: String,
actor: String,
writer_csrf: Option,
+ /// Whether a branch, tag or pull request still reaches the run's commit.
+ reachable: bool,
+}
+
+/// Whether a branch, tag or pull request still reaches `oid`. A force push that overwrote the commit
+/// leaves it unreachable: its run then has no commit link and cannot be run again.
+pub(crate) async fn commit_reachable_for(path: &Path, oid: &str) -> Result {
+ let (path, oid) = (path.to_path_buf(), oid.to_owned());
+ Ok(tokio::task::spawn_blocking(move || commit_reachable(&path, &oid)).await??)
}
/// Whether a job row starts with its tail open: a failed job does, and so does the only job of a run.
@@ -1612,6 +1638,7 @@ async fn run_detail(
let gantt =
(!jobs.is_empty()).then(|| gantt(&jobs, origin_of(run, now), run_end(run, now), now, lang));
let writer = header.writer_csrf.is_some();
+ let rerunnable = writer && header.reachable;
let mut lines = Vec::with_capacity(jobs.len());
let mut artifacts = Vec::new();
for (index, job) in jobs.iter().enumerate() {
@@ -1656,7 +1683,7 @@ async fn run_detail(
name: variant.unwrap_or(job.name.as_str()).to_owned(),
dot: format!("ci-dot ci-{}", job.state.as_str()),
detail: job.image.clone(),
- rerun: (writer && job.state.is_terminal())
+ rerun: (rerunnable && job.state.is_terminal())
.then(|| format!("{}/rerun", job_href(title, &job.id))),
runner: job.runner.clone(),
duration: job.duration.clone(),
@@ -1675,7 +1702,7 @@ async fn run_detail(
truncated,
offset,
first_line,
- } = log_tail(&log_path(&state.config.data_dir, &job.id)).await?;
+ } = log_tail_of(&log_path(&state.config.data_dir, &job.id), RUN_LOG_BYTES).await?;
let href = job_href(title, &job.id);
Some(JobLog {
log_href: format!("{href}/log.txt"),
@@ -1695,7 +1722,7 @@ async fn run_detail(
}
None => None,
};
- let can_rerun_failed = writer
+ let can_rerun_failed = rerunnable
&& run_finished(&run.state)
&& jobs.iter().any(|job| {
matches!(
@@ -1722,7 +1749,10 @@ async fn run_detail(
state_class: format!("ci-state ci-{}", run.state.as_str()),
trigger: trigger_text(lang, &run.trigger),
branch: short_ref(&run.git_ref).to_owned(),
- commit_href: format!("/{title}/commit/{}", run.commit_oid),
+ commit_href: header
+ .reachable
+ .then(|| format!("/{title}/commit/{}", run.commit_oid)),
+ reachable: header.reachable,
commit: short_oid(&run.commit_oid).to_owned(),
actor: header.actor,
when: age_text(lang, &run.created_at),
@@ -1844,7 +1874,7 @@ async fn runs_body(
}
- (g::t(lang, K::RunWorkflow))
+ (g::t(lang, K::RunWorkflow))
@@ -2044,7 +2074,11 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option) -> Resu
@@ -2196,9 +2230,12 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result(g::t(lang, K::LogTruncated))
+
+ (crate::pages::passkeys::s(lang, "Showing the end of this log.", "Günlüğün sonu gösteriliyor."))
+ " " (crate::pages::passkeys::s(lang, "Full log", "Tam günlük"))
+
}
- (log.text.as_str())
+ (log.text.as_str())
} else {
(g::t(lang, K::NoJobs))
}
@@ -2634,6 +2671,12 @@ async fn run_rerun(cx: &Cx, Form(form): Form) -> Result {
require_write(&ctx)?;
let state = app_context::(cx);
let run = run_of(state, &ctx, &number).await?;
+ if !commit_reachable_for(&ctx.path, &run.commit_oid).await? {
+ return Ok(notice_redirect(
+ &run_href(&title_of(&ctx), run.number),
+ "overwritten",
+ ));
+ }
let new_run = state.store.rerun(&run.id, &user.id).await?;
after_change(state, &new_run.id, &[]).await?;
Ok(notice_redirect(
@@ -2655,6 +2698,9 @@ async fn run_rerun_failed(cx: &Cx, Form(form): Form) -> Result(cx);
let run = run_of(state, &ctx, &number).await?;
let href = run_href(&title_of(&ctx), run.number);
+ if !commit_reachable_for(&ctx.path, &run.commit_oid).await? {
+ return Ok(notice_redirect(&href, "overwritten"));
+ }
match state.store.rerun_failed(&run.id, &user.id).await {
Ok(new_run) => {
after_change(state, &new_run.id, &[]).await?;
@@ -2695,6 +2741,12 @@ async fn job_rerun(cx: &Cx, Form(form): Form) -> Result {
if run.repo_id != ctx.repo.id {
return Err(not_found().into());
}
+ if !commit_reachable_for(&ctx.path, &run.commit_oid).await? {
+ return Ok(notice_redirect(
+ &run_href(&title_of(&ctx), run.number),
+ "overwritten",
+ ));
+ }
match state.store.rerun_job(&run.id, &job.id, &user.id).await {
Ok(new_run) => {
after_change(state, &new_run.id, &[]).await?;
diff --git a/crates/forge-web/src/pages/ci_tests.rs b/crates/forge-web/src/pages/ci_tests.rs
index e821563..f40b73e 100644
--- a/crates/forge-web/src/pages/ci_tests.rs
+++ b/crates/forge-web/src/pages/ci_tests.rs
@@ -18,6 +18,7 @@ use crate::ci::{CiLive, artifact_key, log_path};
use crate::test_support::{app_router, create_session, test_state};
const CSRF: &str = "ci-test-csrf";
+/// A hash no ref reaches, standing in for a commit that was overwritten.
const SHA: &str = "0123456789abcdef0123456789abcdef01234567";
const SPEC: &str = r#"{"runs_on":[]}"#;
const RUN_BASE: &str = "/tahinli/proj/ci";
@@ -28,6 +29,8 @@ struct Fixture {
live: Arc,
repo: forge_core::Repo,
tahinli: String,
+ /// The commit `main` points at in `proj`.
+ head: String,
data_dir: PathBuf,
blobs: BlobStore,
}
@@ -59,6 +62,7 @@ async fn fixture(dir: &Path) -> Fixture {
init_bare(&state.git, &bare, "main")
.await
.expect("init bare");
+ let head = commit_main(&bare);
store
.set_collaborator(&repo.id, &bob.id, Role::Write)
.await
@@ -80,11 +84,31 @@ async fn fixture(dir: &Path) -> Fixture {
live,
repo,
tahinli: tahinli.id,
+ head,
data_dir,
blobs,
}
}
+/// Puts one empty commit on `main` and returns its hash.
+fn commit_main(bare: &Path) -> String {
+ let git = |args: &[&str]| {
+ let out = std::process::Command::new("git")
+ .args(["-c", "user.name=t", "-c", "user.email=t@example.com", "-C"])
+ .arg(bare)
+ .args(args)
+ .stdin(std::process::Stdio::null())
+ .output()
+ .expect("git");
+ assert!(out.status.success(), "{args:?}");
+ String::from_utf8_lossy(&out.stdout).trim().to_owned()
+ };
+ let tree = git(&["hash-object", "-t", "tree", "-w", "--stdin"]);
+ let commit = git(&["commit-tree", &tree, "-m", "first"]);
+ git(&["update-ref", "refs/heads/main", &commit]);
+ commit
+}
+
fn cookie_for(token: &str) -> String {
format!("__Host-{SESSION_COOKIE}={token}")
}
@@ -162,7 +186,7 @@ async fn run_with(fx: &Fixture, jobs: &[&str], needs_approval: bool) -> CiRun {
&fx.repo.id,
"push",
"refs/heads/main",
- SHA,
+ &fx.head,
None,
&fx.tahinli,
needs_approval,
@@ -1639,6 +1663,26 @@ async fn rerun_failed_and_rerun_job_start_partial_runs() {
assert!(job_page.contains("Re-run this job"));
}
+#[tokio::test]
+async fn a_run_on_an_overwritten_commit_cannot_be_rerun() {
+ let dir = tempfile::tempdir().expect("tempdir");
+ let fx = fixture(dir.path()).await;
+ run_at(&fx, SHA).await;
+ finish_job(&fx).await;
+ let writer = cookie_for("bob-token");
+ let run_url = format!("{RUN_BASE}/runs/1");
+ let page = get(&fx.app, &run_url, Some(&writer)).await.text();
+ assert!(!page.contains(">Re-run<"));
+ assert!(!page.contains(&format!("/commit/{SHA}")));
+ let refused = post(&fx.app, &format!("{run_url}/rerun"), &writer, &[]).await;
+ assert!(
+ refused
+ .location()
+ .unwrap_or_default()
+ .ends_with("?notice=overwritten")
+ );
+}
+
#[tokio::test]
async fn a_run_with_no_failed_jobs_has_nothing_to_rerun() {
let dir = tempfile::tempdir().expect("tempdir");
diff --git a/crates/forge-web/src/pages/compare.rs b/crates/forge-web/src/pages/compare.rs
index 4656ee3..5563591 100644
--- a/crates/forge-web/src/pages/compare.rs
+++ b/crates/forge-web/src/pages/compare.rs
@@ -431,17 +431,17 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul
Ok(view! {
shell(title: title.as_str(), viewer: ctx.viewer.as_ref(),
repo_head(head: header)
-