Skip to main content

git_commit

Function git_commit 

Source
pub fn git_commit(
    message: &str,
    git_user_name: Option<&str>,
    git_user_email: Option<&str>,
    executor: Option<&dyn ProcessExecutor>,
) -> Result<Option<Oid>>
Expand description

Create a commit.

Similar to git commit -m <message>.

Handles both initial commits (no HEAD yet) and subsequent commits.

§Identity Resolution

The git commit identity (name and email) is resolved using the following priority:

  1. Git config (via libgit2) - primary source
  2. Provided git_user_name and git_user_email parameters (overrides)
  3. Environment variables (RALPH_GIT_USER_NAME, RALPH_GIT_USER_EMAIL)
  4. Ralph config file (read by caller, passed as parameters)
  5. System username + derived email (sane fallback)
  6. Default values (“Ralph Workflow”, “ralph@localhost”) - last resort

Partial overrides are supported: CLI args/env vars/config can override individual fields (name or email) from git config.

§Arguments

  • message - The commit message
  • git_user_name - Optional git user name (overrides git config)
  • git_user_email - Optional git user email (overrides git config)
  • executor - Optional process executor for system username/hostname lookup

§Returns

Returns Ok(Some(oid)) with the commit OID if successful, Ok(None) if the OID is zero (no commit created), or an error if the operation failed.