Implement the in-process structured entry editor

Closes #21
This commit is contained in:
Hermes Agent committed 2026-08-10 07:22:55 +00:00
1 parent cf7a6216ac
commit b503de8b2e
14 files changed
+1547 -37

No files matched your search

+35 -1
View File
@@ -25,7 +25,7 @@ use crate::{
mutation::{TreeCommit, TreeCommitError, TreeCommitter},
recipient::{PolicyCommit, PolicyCommitError, PolicyCommitter},
repository::{EncryptedEntry, Repository, SecretBytes},
write::{EntryCommit, EntryCommitError, EntryCommitter},
write::{EntryCommit, EntryCommitError, EntryCommitter, NoGitEntryCommitter},
};
const DEFAULT_BRANCH: &str = "main";
@@ -38,6 +38,11 @@ pub struct GitIdentity {
}
impl GitIdentity {
pub fn ironstorage() -> Self {
Self::new("IronStorage", "ironstorage@localhost")
.expect("the built-in Git identity is valid")
}
pub fn new(name: impl Into<String>, email: impl Into<String>) -> Result<Self, GitError> {
let name = name.into();
let email = email.into();
@@ -257,6 +262,35 @@ pub struct GitRepository {
identity: GitIdentity,
}
/// Storage-owned selection of pass-compatible automatic Git commits.
pub enum AutomaticEntryCommitter {
Git(Box<GitRepository>),
None(NoGitEntryCommitter),
}
impl AutomaticEntryCommitter {
pub fn for_entry(
repository: &Repository,
entry: &str,
identity: GitIdentity,
) -> Result<Self, GitError> {
match GitRepository::open_innermost(repository, Path::new(entry), identity) {
Ok(git) => Ok(Self::Git(Box::new(git))),
Err(GitError::NotRepository) => Ok(Self::None(NoGitEntryCommitter)),
Err(error) => Err(error),
}
}
}
impl EntryCommitter for AutomaticEntryCommitter {
fn commit(&mut self, change: &EntryCommit) -> Result<(), EntryCommitError> {
match self {
Self::Git(git) => EntryCommitter::commit(git.as_mut(), change),
Self::None(committer) => committer.commit(change),
}
}
}
pub struct GitCredential {
username: String,
password: crate::repository::SecretBytes,