Skip to main content

git_side/commands/
commit.rs

1use colored::Colorize;
2
3use crate::error::Result;
4use crate::side_repo::SideRepo;
5
6/// Commit staged changes to side repo.
7///
8/// # Errors
9///
10/// Returns an error if there's nothing to commit or if the commit fails.
11pub fn run(message: &str) -> Result<()> {
12    let repo = SideRepo::open()?;
13    repo.ensure_initialized()?;
14
15    // Always stage .side-tracked to ensure it's included
16    repo.stage_tracked_file()?;
17
18    repo.commit(message)?;
19
20    println!("{}", "Committed to side repo.".green().bold());
21    Ok(())
22}