Skip to main content

GitEngine

Struct GitEngine 

Source
pub struct GitEngine { /* private fields */ }
Expand description

An embedded git engine bound to one repository.

Implementations§

Source§

impl GitEngine

Source

pub fn open(root: &Path) -> Result<Self, GitError>

Discover and open the repository containing root (walks up for .git).

Source

pub fn status(&self, caps: &GitCaveats) -> Result<StatusReport, GitError>

git status — requires the read capability.

Source

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.

Source

pub fn diff( &self, caps: &GitCaveats, spec: DiffSpec, ) -> Result<DiffReport, GitError>

git diff for the given spec. Requires read.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more