| 631 | ) -> AppResult<Response> { | 631 | ) -> AppResult<Response> { |
| 632 | let branches = git_read(state, &ctx.repo.id, git::Repo::branches).await?; | 632 | let branches = git_read(state, &ctx.repo.id, git::Repo::branches).await?; |
| 633 | let branch_list: Vec<String> = branches.iter().map(|b| b.name.clone()).collect(); | 633 | let branch_list: Vec<String> = branches.iter().map(|b| b.name.clone()).collect(); |
| | 634 | let base = format!("/{}/{}", ctx.owner.username, ctx.repo.path); |
| | 635 | let now = crate::now_ms(); |
| 634 | let body = html! { | 636 | let body = html! { |
| 635 | (repo_header(state, &ctx, Tab::Branches, &ctx.repo.default_branch, &branch_list)) | 637 | (repo_header(state, &ctx, Tab::Branches, &ctx.repo.default_branch, &branch_list)) |
| 636 | h2 { "Branches" } | 638 | h2 { "Branches" } |
| 637 | table class="list" { | 639 | ul class="entry-list card" { |
| 638 | thead { tr { th { "Branch" } th { "Ahead" } th { "Behind" } th { "Updated" } } } | 640 | @for b in &branches { |
| 639 | tbody { | 641 | li class="entry-row" { |
| 640 | @for b in &branches { | 642 | div class="entry-row-body" { |
| 641 | tr { | 643 | a class="entry-row-title" href=(format!("{base}/-/tree/{}", b.name)) { (b.name) } |
| 642 | td { | 644 | div class="entry-row-meta muted" { |
| 643 | a href={ "/" (ctx.owner.username) "/" (ctx.repo.path) "/-/tree/" (b.name) } { (b.name) } | 645 | @if b.ahead > 0 { |
| 644 | @if b.is_default { " " span class="badge" { "default" } } | 646 | span class="ahead" { "↑" (b.ahead) } |
| | 647 | } |
| | 648 | @if b.behind > 0 { |
| | 649 | span class="behind" { "↓" (b.behind) } |
| | 650 | } |
| | 651 | span { "Updated " (crate::activity::fmt_relative(b.tip.author.time_ms, now)) } |
| | 652 | span { "by " (b.tip.author.name) } |
| | 653 | } |
| | 654 | } |
| | 655 | div class="entry-row-actions" { |
| | 656 | @if b.is_default { span class="badge badge-default" { "default" } } |
| | 657 | a class="mono commit-sha-pill" href=(format!("{base}/-/commit/{}", b.oid)) { |
| | 658 | (b.oid.short()) |
| 645 | } | 659 | } |
| 646 | td { @if b.ahead > 0 { span style="color:var(--fb-success)" { (b.ahead) } } @else { "0" } } | | |
| 647 | td { (b.behind) } | | |
| 648 | td class="muted" { (b.tip.author.name) " · " (fmt_date(b.tip.author.time_ms)) } | | |
| 649 | } | 660 | } |
| 650 | } | 661 | } |
| 651 | } | 662 | } |
| 667 | ) -> AppResult<Response> { | 678 | ) -> AppResult<Response> { |
| 668 | let tags = git_read(state, &ctx.repo.id, git::Repo::tags).await?; | 679 | let tags = git_read(state, &ctx.repo.id, git::Repo::tags).await?; |
| 669 | let branches = branch_names(state, &ctx.repo.id).await; | 680 | let branches = branch_names(state, &ctx.repo.id).await; |
| | 681 | let base = format!("/{}/{}", ctx.owner.username, ctx.repo.path); |
| 670 | let body = html! { | 682 | let body = html! { |
| 671 | (repo_header(state, &ctx, Tab::Tags, &ctx.repo.default_branch, &branches)) | 683 | (repo_header(state, &ctx, Tab::Tags, &ctx.repo.default_branch, &branches)) |
| 672 | h2 { "Tags" } | 684 | h2 { "Tags" } |
| 673 | table class="list" { | 685 | @if tags.is_empty() { |
| 674 | thead { tr { th { "Tag" } th { "Commit" } th { "Kind" } } } | 686 | div class="card" { p class="muted" { "No tags." } } |
| 675 | tbody { | 687 | } @else { |
| | 688 | ul class="entry-list card" { |
| 676 | @for t in &tags { | 689 | @for t in &tags { |
| 677 | tr { | 690 | li class="entry-row" { |
| 678 | td { a href={ "/" (ctx.owner.username) "/" (ctx.repo.path) "/-/tree/" (t.name) } { (t.name) } } | 691 | div class="entry-row-body" { |
| 679 | td class="mono" { (t.oid.short()) } | 692 | a class="entry-row-title" href=(format!("{base}/-/tree/{}", t.name)) { (t.name) } |
| 680 | td { (if t.annotated { "annotated" } else { "lightweight" }) } | 693 | div class="entry-row-meta muted" { |
| | 694 | span { (if t.annotated { "annotated" } else { "lightweight" }) } |
| | 695 | } |
| | 696 | } |
| | 697 | div class="entry-row-actions" { |
| | 698 | a class="mono commit-sha-pill" href=(format!("{base}/-/commit/{}", t.oid)) { |
| | 699 | (t.oid.short()) |
| | 700 | } |
| | 701 | } |
| 681 | } | 702 | } |
| 682 | } | 703 | } |
| 683 | } | 704 | } |
| 742 | let body = html! { | 763 | let body = html! { |
| 743 | (repo_header(state, &ctx, Tab::Commits, &rev_name, &branches)) | 764 | (repo_header(state, &ctx, Tab::Commits, &rev_name, &branches)) |
| 744 | h2 { "Commits" } | 765 | h2 { "Commits" } |
| 745 | ul class="commit-list card" { | 766 | ul class="entry-list card" { |
| 746 | @for (commit, sig) in commits.iter().zip(states.iter()) { | 767 | @for (commit, sig) in commits.iter().zip(states.iter()) { |
| 747 | @let commit_url = format!("{base}/-/commit/{}", commit.oid); | 768 | @let commit_url = format!("{base}/-/commit/{}", commit.oid); |
| 748 | @let signer = match sig { | 769 | @let signer = match sig { |
| 749 | git::SignatureState::Verified { user_id, .. } => signers.get(user_id).map(String::as_str), | 770 | git::SignatureState::Verified { user_id, .. } => signers.get(user_id).map(String::as_str), |
| 750 | _ => None, | 771 | _ => None, |
| 751 | }; | 772 | }; |
| 752 | li class="commit-row" { | 773 | li class="entry-row" { |
| 753 | div class="commit-row-body" { | 774 | div class="entry-row-body" { |
| 754 | a class="commit-row-msg" href=(commit_url) { (commit.summary) } | 775 | a class="entry-row-title" href=(commit_url) { (commit.summary) } |
| 755 | div class="commit-row-meta muted" { | 776 | div class="entry-row-meta muted" { |
| 756 | span { (commit.author.name) } | 777 | span { (commit.author.name) } |
| 757 | span { "·" } | 778 | span { "·" } |
| 758 | span { (crate::activity::fmt_relative(commit.author.time_ms, now)) } | 779 | span { (crate::activity::fmt_relative(commit.author.time_ms, now)) } |
| 759 | } | 780 | } |
| 760 | } | 781 | } |
| 761 | div class="commit-row-actions" { | 782 | div class="entry-row-actions" { |
| 762 | (commit_sig_cell(sig, signer, commit.author.time_ms)) | 783 | (commit_sig_cell(sig, signer, commit.author.time_ms)) |
| 763 | a class="mono commit-sha-pill" href=(commit_url) { (commit.oid.short()) } | 784 | a class="mono commit-sha-pill" href=(commit_url) { (commit.oid.short()) } |
| 764 | button class="icon-btn commit-copy" type="button" | 785 | button class="icon-btn commit-copy" type="button" |