From ec20c04ae73cec5f503efe38c1977a9622cf5b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 24 Oct 2026 06:07:42 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20an=20empty=20repo's=20hom?= =?UTF-8?q?e=20page=20goes=20live=20on=20its=20first=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/src/pages/code_live.rs | 10 ++++++---- crates/forge-web/src/pages/repo.rs | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/forge-web/src/pages/code_live.rs b/crates/forge-web/src/pages/code_live.rs index 496a8d7..bb88119 100644 --- a/crates/forge-web/src/pages/code_live.rs +++ b/crates/forge-web/src/pages/code_live.rs @@ -35,13 +35,15 @@ pub fn follows_branch(refs: &[RefInfo], ref_name: &str) -> bool { .any(|r| r.kind == RefKind::Branch && r.name == ref_name) } +/// The stream URL of a code view that follows `branch`, whether or not the branch exists yet. +pub fn branch_live_url(owner: &str, repo: &str, branch: &str) -> String { + format!("/{owner}/{repo}/events?ref_name={}", percent_encode(branch)) +} + /// The stream URL of a repo page. A code view of a branch adds the branch to it. pub fn live_url(owner: &str, repo: &str, refs: &[RefInfo], ref_name: &str) -> String { if follows_branch(refs, ref_name) { - format!( - "/{owner}/{repo}/events?ref_name={}", - percent_encode(ref_name) - ) + branch_live_url(owner, repo, ref_name) } else { format!("/{owner}/{repo}/events") } diff --git a/crates/forge-web/src/pages/repo.rs b/crates/forge-web/src/pages/repo.rs index 1573c3d..1f16224 100644 --- a/crates/forge-web/src/pages/repo.rs +++ b/crates/forge-web/src/pages/repo.rs @@ -20,7 +20,7 @@ use topcoat::view::{View, component, view}; use crate::i18n::code::{self as g, K}; use crate::i18n::{self, Lang}; -use crate::pages::code_live::{follows_branch, live_url}; +use crate::pages::code_live::{branch_live_url, follows_branch}; use crate::pages::dashboard::badge_class; use crate::pages::finder::file_finder; use crate::pages::issue_parts::stamp_unix; @@ -467,7 +467,8 @@ async fn repo_page(cx: &Cx) -> Result { )); } let follows = follows_branch(&refs, &branch); - let live = live_url(&repo.owner_name, &repo.name, &refs, &branch); + // The home page follows the default branch even before its first push, so that push goes live. + let live = branch_live_url(&repo.owner_name, &repo.name, &branch); let owner_name = repo.owner_name.clone(); let repo_name = repo.name.clone(); let branches_href = repo_href(&owner_name, &repo_name, "branches", "");