Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,17 @@ pub fn pre_commit_check(pre_commit_command: Option<String>, message: &str) -> Re
}
Ok(())
}

pub fn git_add_all_modified() -> Result<()> {
let output = git_exec(&["add", "-u"])?;
std::io::stdout().write_all(&output.stdout)?;
std::io::stderr().write_all(&output.stderr)?;

if !output.status.success() {
return Err(anyhow!(
"Failed to get git path. Make sure you are in a git repository"
));
}

Ok(())
}
16 changes: 14 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
clippy::cargo,
clippy::str_to_string
)]
#![allow(clippy::module_name_repetitions, clippy::multiple_crate_versions)]
#![allow(
clippy::module_name_repetitions,
clippy::multiple_crate_versions,
clippy::struct_excessive_bools
)]

mod commit;
mod commit_message;
Expand All @@ -17,7 +21,8 @@ use std::io::Write;
use std::path::PathBuf;

use commit::{
check_staged_files, commit, pre_commit_check, read_cached_commit, write_cached_commit,
check_staged_files, commit, git_add_all_modified, pre_commit_check, read_cached_commit,
write_cached_commit,
};
use commit_message::make_message_commit;

Expand All @@ -38,11 +43,18 @@ struct Args {
/// Retry commit with the same message as the last one
#[arg(short, long)]
retry: bool,
/// Add all modified files into staging
#[arg(short, long)]
all: bool,
}

fn main() -> Result<()> {
let args = Args::parse();

if args.all {
git_add_all_modified()?;
}

check_staged_files()?;

if args.init {
Expand Down