22GVE2654AUPLXTR5D2CJTZPPDRB2MYHRDZW2EDTSNQXVVSZHA5AC /// # Pijul Client Interaction/// - **Endpoint**: `GET /.pijul?tag={hash}`/// - **Called by**: `Http::download_changes()` in pijul-remote/src/http.rs (for tags)/// - **Response format**: Binary tag file content (`application/octet-stream`)/// - **Purpose**: Downloads tag/state files. The changelist response/// indicates which entries are tags (trailing `.`), and the client downloads/// these via this endpoint.////// # File Location/// Tags are stored at: `.pijul/tags/{first-2-chars}/{rest}.tag`/// Example: hash `XYZABC789` -> `.pijul/tags/XY/ZABC789.tag`
/// Can't get this to work with nest.pijul.org.
if hash.len() < 3 || !hash.chars().all(|c| c.is_ascii_alphanumeric()) {return not_found("invalid tag hash");}let (pfx, sfx) = hash.split_at(2);let path = repo_path.join(".pijul").join("tags").join(pfx).join(format!("{}.tag", sfx));serve_file(&path, "application/octet-stream")
dbg!(repo_path, hash);todo!("No reference implementation")
/// # Pijul Client Interaction/// - **Endpoint**: `GET /.pijul?identities` or `GET /.pijul?identities={rev}`/// - **Called by**: `Http::update_identities()` in pijul-remote/src/http.rs/// - **Response format**: JSON `{"id":[...],"rev":N}`/// - `id`: Array of identity certificates (currently empty)/// - `rev`: Revision number for incremental updates/// - **Purpose**: Pijul supports cryptographic identity verification. The client/// requests identities to verify change authorship and establish trust./// The `rev` parameter allows incremental updates (only fetch new identities/// since a given revision).////// # Current Implementation/// Returns empty identity list. A full implementation would read from/// `.pijul/identities/` and return serialized identity certificates.
/// Current Implementation on nest.pijul.org seems to only return/// `{"id": [], "rev": 0}`, and does so here as well.
#[test]fn test_serve_tag_hash_too_short() {let dir = TempDir::new().unwrap();let resp = serve_tag(dir.path(), "ab");assert_eq!(get_status(&resp), 404);}
// #[test]// fn test_serve_tag_hash_too_short() {// let dir = TempDir::new().unwrap();// let resp = serve_tag(dir.path(), "ab");// assert_eq!(get_status(&resp), 404);// }
#[test]fn test_serve_tag_valid_hash_file_exists() {let dir = TempDir::new().unwrap();let tag_dir = dir.path().join(".pijul").join("tags").join("ab");
// #[test]// fn test_serve_tag_valid_hash_file_exists() {// let dir = TempDir::new().unwrap();// let tag_dir = dir.path().join(".pijul").join("tags").join("ab");
fs::create_dir_all(&tag_dir).unwrap();let tag_file = tag_dir.join("cdef123.tag");fs::File::create(&tag_file).unwrap().write_all(b"tag data").unwrap();
// fs::create_dir_all(&tag_dir).unwrap();// let tag_file = tag_dir.join("cdef123.tag");// fs::File::create(&tag_file)// .unwrap()// .write_all(b"tag data")// .unwrap();
let resp = serve_tag(dir.path(), "abcdef123");assert_eq!(get_status(&resp), 200);assert_eq!(get_header(&resp, "Content-Type"),Some("application/octet-stream"));}
// let resp = serve_tag(dir.path(), "abcdef123");// assert_eq!(get_status(&resp), 200);// assert_eq!(// get_header(&resp, "Content-Type"),// Some("application/octet-stream")// );// }