commit_version_changes

Function commit_version_changes 

Source
pub fn commit_version_changes(
    repo: &Repo,
    modified_files: &[impl AsRef<Path>],
    commit_message: &str,
) -> Result<String>
Expand description

Commits version changes to the Git repository.

Stages the provided files and creates a commit with the specified message. This operation is atomic - either all files are committed or none are.

§Arguments

  • repo - Git repository instance
  • modified_files - List of files that were modified during version bump
  • commit_message - Commit message to use

§Returns

Returns the commit SHA on success, or an error if the operation fails.

§Errors

Returns an error if:

  • Files cannot be staged
  • Commit creation fails
  • Repository is in an invalid state

§Examples

use sublime_git_tools::Repo;
use std::path::PathBuf;

let repo = Repo::open(".")?;
let files = vec![PathBuf::from("package.json")];
let sha = commit_version_changes(&repo, &files, "chore: bump version to 1.2.0")?;
println!("Created commit: {}", sha);