pub struct GitEngine { /* private fields */ }Expand description
An embedded git engine bound to one repository.
Implementations§
Source§impl GitEngine
impl GitEngine
Sourcepub fn open(root: &Path) -> Result<Self, GitError>
pub fn open(root: &Path) -> Result<Self, GitError>
Discover and open the repository containing root (walks up for .git).
Sourcepub fn status(&self, caps: &GitCaveats) -> Result<StatusReport, GitError>
pub fn status(&self, caps: &GitCaveats) -> Result<StatusReport, GitError>
git status — requires the read capability.
Sourcepub fn log(
&self,
caps: &GitCaveats,
limit: usize,
) -> Result<Vec<CommitInfo>, GitError>
pub fn log( &self, caps: &GitCaveats, limit: usize, ) -> Result<Vec<CommitInfo>, GitError>
git log — a first-parent walk from HEAD, up to limit commits. Requires read.
Sourcepub fn diff(
&self,
caps: &GitCaveats,
spec: DiffSpec,
) -> Result<DiffReport, GitError>
pub fn diff( &self, caps: &GitCaveats, spec: DiffSpec, ) -> Result<DiffReport, GitError>
git diff for the given spec. Requires read.
Sourcepub fn add(
&self,
caps: &GitCaveats,
paths: &[String],
) -> Result<Vec<String>, GitError>
pub fn add( &self, caps: &GitCaveats, paths: &[String], ) -> Result<Vec<String>, GitError>
git add — stage worktree files into the index. Requires stage.
Each path is repository-relative. Returns the paths actually staged.
Sourcepub fn commit(
&self,
caps: &GitCaveats,
message: &str,
author: &Author,
) -> Result<CommitInfo, GitError>
pub fn commit( &self, caps: &GitCaveats, message: &str, author: &Author, ) -> Result<CommitInfo, GitError>
git commit — build a tree from the index, write the commit, and advance the
current branch. Requires commit_local. Errors on detached HEAD.
Sourcepub fn amend(
&self,
caps: &GitCaveats,
message: Option<&str>,
author: &Author,
) -> Result<CommitInfo, GitError>
pub fn amend( &self, caps: &GitCaveats, message: Option<&str>, author: &Author, ) -> Result<CommitInfo, GitError>
git commit --amend — replace HEAD with a new commit carrying the
current index tree, keeping HEAD’s PARENTS (not HEAD itself). message
None reuses HEAD’s existing message (amend-to-add-files); Some rewords
it. Requires commit_local. Errors on an unborn / detached HEAD.
Sourcepub fn rebase(
&self,
caps: &GitCaveats,
onto: &str,
steps: &[RebaseStep],
author: &Author,
) -> Result<RebaseReport, GitError>
pub fn rebase( &self, caps: &GitCaveats, onto: &str, steps: &[RebaseStep], author: &Author, ) -> Result<RebaseReport, GitError>
Structured-plan rebase: replay steps (in order) onto onto, applying
pick / reword / squash / fixup / drop. All new trees and commits are
written to the ODB; the branch ref is advanced only at the very end,
so a conflict (or any error) aborts with the branch unchanged — no
working-tree, index, or ref side effects. Requires commit_local.
Cherry-pick per step is a 3-way tree merge with MergeFavor::None so
real conflicts are reported (not silently resolved). Authorship on the
produced commits is the agent’s (the typical case: rewriting its own
recent history). Root commits (no parent) cannot be replayed.
Sourcepub fn branch(&self, caps: &GitCaveats, name: &str) -> Result<String, GitError>
pub fn branch(&self, caps: &GitCaveats, name: &str) -> Result<String, GitError>
git branch <name> — create refs/heads/<name> at the current HEAD commit.
Requires refs to permit that ref name. Returns the full ref name.
Sourcepub fn checkout(
&self,
caps: &GitCaveats,
name: &str,
create: bool,
) -> Result<String, GitError>
pub fn checkout( &self, caps: &GitCaveats, name: &str, create: bool, ) -> Result<String, GitError>
git checkout [-b] <name> — point HEAD at branch <name>, creating it at
the current commit first when create is set (the -b case the model
reaches for). Requires refs to permit the branch ref.
newt is local-only and has no working-tree updater, so this only moves HEAD when the target branch is at the SAME commit as the current HEAD (always true for a freshly-created branch). Switching to a branch at a different commit is refused rather than silently leaving the worktree stale — no side effects on refusal.
Sourcepub fn branch_delete(
&self,
caps: &GitCaveats,
name: &str,
) -> Result<String, GitError>
pub fn branch_delete( &self, caps: &GitCaveats, name: &str, ) -> Result<String, GitError>
git branch -d <name> — delete refs/heads/<name>. Requires refs to
permit the ref. Refuses to delete the branch HEAD is currently on, or a
branch that does not exist (no side effects on refusal).
Auto Trait Implementations§
impl Freeze for GitEngine
impl RefUnwindSafe for GitEngine
impl Send for GitEngine
impl Sync for GitEngine
impl Unpin for GitEngine
impl UnsafeUnpin for GitEngine
impl UnwindSafe for GitEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more