use crate::api;
use crate::command;
use crate::error;
use crate::error::OxenError;
use crate::model::{Commit, LocalRepository};
pub fn commit(repo: &LocalRepository, message: &str) -> Result<Commit, OxenError> {
let status = command::status(repo)?;
if !status.has_added_entries() && status.staged_schemas.is_empty() {
return Err(OxenError::NothingToCommit(
error::string_error::StringError::new(
r"No files are staged, not committing.
Stage a file or directory with `oxen add <file>`"
.to_string(),
),
));
}
let commit = api::local::commits::commit(repo, &status, message)?;
log::info!("DONE COMMITTING in command::commit {}", commit);
Ok(commit)
}