| | @@ -46,7 +46,7 @@ use crate::{ |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | 48 | use super::{ |
| 49 | | − blame::{FileTab, view_toggle}, |
| 49 | + blame::{FileTab, blame_url, view_toggle}, |
| 50 | 50 | commit::commit_url, |
| 51 | 51 | context::{current_actor, memberships, orgs, queries, repos, server_error}, |
| 52 | 52 | layout::wide, |
| | @@ -180,7 +180,7 @@ pub(super) async fn browsed_at( |
| 180 | 180 | /// [0006](../../plans/decisions/0006-git-binary-behind-narrow-ports.md). Called only by |
| 181 | 181 | /// the pages that show the switcher, and skipped for a repository with no commits, |
| 182 | 182 | /// where there is nothing to list. |
| 183 | | −async fn refs_for(cx: &Cx, repo: &RepoView) -> Result<RefList> { |
| 183 | +pub(super) async fn refs_for(cx: &Cx, repo: &RepoView) -> Result<RefList> { |
| 184 | 184 | Ok(list_refs( |
| 185 | 185 | &repo.handle, |
| 186 | 186 | &repo.name, |
| | @@ -423,23 +423,24 @@ pub(super) fn log_url(handle: &str, name: &str, rev: &str) -> String { |
| 423 | 423 | |
| 424 | 424 | /// Which page a switcher's links lead back to. |
| 425 | 425 | /// |
| 426 | | −/// Switching branch keeps you where you are: the same path on the tree, the log on the |
| 427 | | −/// log. A path that does not exist on the revision you picked lands on a 404, which is |
| 428 | | −/// the honest answer — the alternative is silently sending you somewhere you did not |
| 429 | | −/// ask for. |
| 430 | | −enum Switch<'a> { |
| 426 | +/// Switching branch keeps you where you are: the same path on the tree, the same path |
| 427 | +/// on blame, the log on the log. A path that does not exist on the revision you picked |
| 428 | +/// lands on a 404, which is the honest answer — the alternative is silently sending you |
| 429 | +/// somewhere you did not ask for. |
| 430 | +pub(super) enum Switch<'a> { |
| 431 | 431 | Tree(&'a RepoPath), |
| 432 | + Blame(&'a RepoPath), |
| 432 | 433 | Log, |
| 433 | 434 | } |
| 434 | 435 | |
| 435 | 436 | /// One row of the switcher. |
| 436 | | −struct RefLink { |
| 437 | +pub(super) struct RefLink { |
| 437 | 438 | name: String, |
| 438 | 439 | href: String, |
| 439 | 440 | current: bool, |
| 440 | 441 | } |
| 441 | 442 | |
| 442 | | −fn ref_links( |
| 443 | +pub(super) fn ref_links( |
| 443 | 444 | handle: &str, |
| 444 | 445 | name: &str, |
| 445 | 446 | refs: &[RefName], |
| | @@ -451,6 +452,7 @@ fn ref_links( |
| 451 | 452 | name: git_ref.to_string(), |
| 452 | 453 | href: match switch { |
| 453 | 454 | Switch::Tree(path) => tree_url(handle, name, git_ref, path), |
| 455 | + Switch::Blame(path) => blame_url(handle, name, git_ref, path), |
| 454 | 456 | Switch::Log => log_url(handle, name, git_ref.as_str()), |
| 455 | 457 | }, |
| 456 | 458 | current: git_ref.as_str() == current, |
| | @@ -663,7 +665,7 @@ fn counted(count: usize, one: &str, many: &str) -> String { |
| 663 | 665 | /// Renders nothing at all when there is neither a revision nor a ref to offer, which is |
| 664 | 666 | /// an empty repository. |
| 665 | 667 | #[component] |
| 666 | | −async fn rev_switcher( |
| 668 | +pub(super) async fn rev_switcher( |
| 667 | 669 | current: &str, |
| 668 | 670 | known: bool, |
| 669 | 671 | branches: &[RefLink], |