Skip to main content

solid_pod_rs_git/
lib.rs

1//! # solid-pod-rs-git
2//!
3//! Git HTTP smart-protocol backend for
4//! [`solid-pod-rs`](https://crates.io/crates/solid-pod-rs).
5//!
6//! ## Modules
7//!
8//! - [`service`] — Framework-agnostic [`GitHttpService`] that speaks `git-http-backend` CGI.
9//! - [`auth`]    — `Basic nostr:<token>` and NIP-98 bearer auth extractors.
10//! - [`guard`]   — Path-traversal rejection and repo-slug extraction.
11//! - [`config`]  — Git repository config helpers (`receive.denyCurrentBranch`, etc.).
12//! - [`mark`]    — [`ShellGitMarker`]: native `GitMarker` (write-as-commit provenance).
13//! - [`error`]   — [`GitError`] enum with HTTP status-code mapping.
14//!
15//! ## Quick start
16//!
17//! ```no_run
18//! use std::path::PathBuf;
19//! use solid_pod_rs_git::{GitHttpService, BasicNostrExtractor};
20//!
21//! # async fn run() {
22//! // Create the service rooted at a pod's data directory.
23//! let service = GitHttpService::new(PathBuf::from("/var/pods/alice"))
24//!     .with_auth(BasicNostrExtractor::new());
25//!
26//! // In your HTTP router, translate framework types to GitRequest and call:
27//! // let response = service.handle(git_request).await;
28//! # }
29//! ```
30//!
31//! ## Feature flags
32//!
33//! | Flag              | Purpose                                         |
34//! |-------------------|-------------------------------------------------|
35//! | `with-git-binary` | Enable integration tests that need the `git` CLI and `git-http-backend` CGI binary. Unit tests always run. |
36//!
37//! ## Architecture
38//!
39//! The crate is framework-agnostic: [`GitHttpService`] consumes a
40//! [`GitRequest`] and produces a [`GitResponse`]. The embedding HTTP
41//! server (axum, actix-web, hyper, ...) translates between its native
42//! types and these. Internally the service spawns `git http-backend`
43//! (path overridable via `GIT_HTTP_BACKEND_PATH`) and shuttles bytes.
44
45#![doc = include_str!("../README.md")]
46#![deny(unsafe_code)]
47#![warn(missing_docs)]
48#![warn(rust_2018_idioms)]
49
50pub mod api;
51pub mod auth;
52pub mod config;
53pub mod error;
54pub mod guard;
55pub mod init;
56pub mod mark;
57pub mod service;
58
59pub use api::{
60    git_add, git_branches, git_commit, git_create_branch, git_diff, git_discard, git_log,
61    git_status, git_unstage, resolve_commit, BranchInfo, ChangeType, CommitEntry, CommitResult,
62    FileStatus, ResolvedCommit, StatusReport,
63};
64pub use auth::{AuthError, BasicNostrExtractor, GitAuth};
65pub use config::{find_git_dir, GitDir};
66pub use error::GitError;
67pub use guard::{extract_repo_slug, path_safe};
68pub use init::GitAutoInit;
69pub use mark::ShellGitMarker;
70pub use service::{GitHttpService, GitRequest, GitResponse, DEFAULT_GIT_HTTP_BACKEND};