pub struct GitCommitService { /* private fields */ }Expand description
Service for performing git commit operations
This service handles:
- Creating commits with optional hook verification
- Pre-commit hook execution
- Remote repository detection
It does NOT handle:
- LLM operations (handled by
IrisAgentService) - Context gathering (handled by agents)
- Message generation (handled by agents)
Implementations§
Source§impl GitCommitService
impl GitCommitService
Sourcepub fn new(repo: Arc<GitRepo>, _use_gitmoji: bool, verify: bool) -> Self
pub fn new(repo: Arc<GitRepo>, _use_gitmoji: bool, verify: bool) -> Self
Create a new GitCommitService
§Arguments
repo- The git repository to operate on_use_gitmoji- Retained for API compatibility; commit messages are stored exactly as providedverify- Whether to run pre/post-commit hooks
Sourcepub fn from_repo(repo: GitRepo, use_gitmoji: bool, verify: bool) -> Self
pub fn from_repo(repo: GitRepo, use_gitmoji: bool, verify: bool) -> Self
Create from an existing GitRepo (convenience constructor)
Sourcepub fn pre_commit(&self) -> Result<()>
pub fn pre_commit(&self) -> Result<()>
Execute the pre-commit hook if verification is enabled
Returns Ok(()) if:
- verify is false (hooks disabled)
- repository is remote (hooks don’t apply)
- pre-commit hook succeeds
§Errors
Returns an error when hook verification is enabled and the pre-commit hook fails.
Sourcepub fn perform_commit(&self, message: &str) -> Result<CommitResult>
pub fn perform_commit(&self, message: &str) -> Result<CommitResult>
Perform a commit with the given message
This method:
- Validates the repository is not remote
- Uses the exact message provided
- Runs pre-commit hook (if verify is enabled)
- Creates the commit
- Runs post-commit hook (if verify is enabled)
§Arguments
message- The commit message to use
§Returns
The result of the commit operation
§Errors
Returns an error when the repository is remote, hooks fail, or Git cannot create the commit.
Sourcepub fn perform_amend(&self, message: &str) -> Result<CommitResult>
pub fn perform_amend(&self, message: &str) -> Result<CommitResult>
Amend the previous commit with staged changes and a new message
This method:
- Validates the repository is not remote
- Uses the exact message provided
- Runs pre-commit hook (if verify is enabled)
- Amends the commit (replaces HEAD)
- Runs post-commit hook (if verify is enabled)
§Arguments
message- The new commit message
§Returns
The result of the amend operation
§Errors
Returns an error when the repository is remote, hooks fail, or Git cannot amend the commit.
Sourcepub fn get_head_commit_message(&self) -> Result<String>
pub fn get_head_commit_message(&self) -> Result<String>
Get the message of the HEAD commit
Useful for amend operations to provide original context
§Errors
Returns an error when the HEAD commit cannot be read.
Auto Trait Implementations§
impl Freeze for GitCommitService
impl RefUnwindSafe for GitCommitService
impl Send for GitCommitService
impl Sync for GitCommitService
impl Unpin for GitCommitService
impl UnsafeUnpin for GitCommitService
impl UnwindSafe for GitCommitService
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
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> 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