git-ents.gitmain
⌘K
foforge
inbox.rs47 lines · 1.3 KB · rusthistorycomment on this file
1//! `GET /inbox`: every `refs/meta/inbox/<member>/<id>` entry awaiting
2//! adoption -- read-only in this phase (`sync.adoption-machinery`'s merge
3//! itself stays a `git ents inbox adopt` operation; this crate has no
4//! write path for it, since adoption needs a working-tree-aware three-way
5//! merge, not a signed-commit form).
6
7use std::sync::Arc;
8
9use axum::extract::State;
10use gix_object::{Find, Write};
11
12use crate::error::Result;
13use crate::state::AppState;
14
15/// `GET /inbox`.
16///
17/// # Errors
18///
19/// Propagates a ref-store read failure.
20pub async fn list<O>(State(state): State<Arc<AppState<O>>>) -> Result<maud::Markup>
21where
22 O: Find + Write + Send + 'static,
23{
24 let mut rows = Vec::new();
25 for entry in state.refs.iter_prefix("refs/meta/inbox/")? {
26 let (name, _) = entry?;
27 let path = name.as_bstr().to_string();
28 if let Some(rest) = path.strip_prefix("refs/meta/inbox/") {
29 rows.push(rest.to_owned());
30 }
31 }
32 let body = if rows.is_empty() {
33 super::blankslate(
34 "Inbox is empty",
35 maud::html! { "Entries awaiting adoption appear here." },
36 )
37 } else {
38 crate::render::string_list(&rows, |_| "/inbox".to_owned())
39 };
40 Ok(super::layout_meta(
41 &super::RepoHeader::from_state(&state),
42 &super::identity_label(&state),
43 "/inbox",
44 "Inbox",
45 body,
46 ))
47}