pub fn commit_with_git(
repo: &Repository,
message: &str,
gpgsign: bool,
signkey: Option<&str>,
) -> Result<(), Box<dyn Error>>
Expand description
Commits the currently staged changes with the provided commit message.
This function handles both initial and regular commits, constructing the commit tree and linking to the correct parent if available.
§Arguments
repo
- A reference to an opengit2::Repository
instance.message
- The commit message to use.
§Errors
Returns a boxed Error
if Git operations (e.g., getting the index, writing tree, or committing) fail.
§Example
use git_commit_helper::commit_with_git;
use git2::Repository;
let repo = Repository::discover(".").expect("Not a git repository");
let message = "Add README and initial setup";
if let Err(err) = commit_with_git(&repo, message) {
eprintln!("Commit failed: {}", err);
}