pub struct StageManager<'a> { /* private fields */ }Expand description
Manager for repository staging area
Provides operations similar to git add and git rm commands.
§Examples
ⓘ
// Add file to staging area
repo.staging().add("src/main.rs")?;
// Add all changes
repo.staging().add_all()?;
// Remove file from staging area
repo.staging().remove("old.txt")?;
// Check what's staged
let staged = repo.staging().status()?;
for file in staged {
println!("{:?}: {}", file.status, file.path);
}Implementations§
Source§impl<'a> StageManager<'a>
impl<'a> StageManager<'a>
Sourcepub async fn add(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
pub async fn add(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
Add a file or directory to the staging area
Similar to git add <path>
Sourcepub async fn add_all(&self) -> Git2DBResult<()>
pub async fn add_all(&self) -> Git2DBResult<()>
Add all changes to the staging area
Similar to git add -A or git add .
Sourcepub async fn remove(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
pub async fn remove(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
Remove a file from the staging area and working directory
Similar to git rm <path>
Sourcepub async fn unstage(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
pub async fn unstage(&self, path: impl AsRef<Path>) -> Git2DBResult<()>
Unstage a file (remove from staging area but keep changes)
Similar to git reset HEAD <path>
Sourcepub async fn reset(&self) -> Git2DBResult<()>
pub async fn reset(&self) -> Git2DBResult<()>
Reset all staged changes
Similar to git reset HEAD
Sourcepub async fn status(&self) -> Git2DBResult<Vec<StagedFile>>
pub async fn status(&self) -> Git2DBResult<Vec<StagedFile>>
Get status of all files in the repository
Returns information about staged and unstaged changes.
Sourcepub async fn staged_files(&self) -> Git2DBResult<Vec<StagedFile>>
pub async fn staged_files(&self) -> Git2DBResult<Vec<StagedFile>>
Get only staged files
Returns files that are ready to be committed.
Sourcepub async fn is_empty(&self) -> Git2DBResult<bool>
pub async fn is_empty(&self) -> Git2DBResult<bool>
Check if staging area is empty
Trait Implementations§
Source§impl<'a> RepositoryAccessor for StageManager<'a>
impl<'a> RepositoryAccessor for StageManager<'a>
Source§fn repo_path(&self) -> Git2DBResult<PathBuf>
fn repo_path(&self) -> Git2DBResult<PathBuf>
Get the repository worktree path
Source§fn open_repo(
&self,
) -> impl Future<Output = Git2DBResult<Repository>> + Send + '_where
Self: Sync,
fn open_repo(
&self,
) -> impl Future<Output = Git2DBResult<Repository>> + Send + '_where
Self: Sync,
Open the git repository (async, uses spawn_blocking) Read more
Auto Trait Implementations§
impl<'a> Freeze for StageManager<'a>
impl<'a> !RefUnwindSafe for StageManager<'a>
impl<'a> Send for StageManager<'a>
impl<'a> Sync for StageManager<'a>
impl<'a> Unpin for StageManager<'a>
impl<'a> UnsafeUnpin for StageManager<'a>
impl<'a> !UnwindSafe for StageManager<'a>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
Mutably borrows from an owned value. Read more
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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 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>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more