Skip to content

Commit

Permalink
feat(commit): intend to add and patch unstaged changes
Browse files Browse the repository at this point in the history
To avoid forgetting to commit unstaged changes, commit will run `git add -N && git add -p` before showing the wizzard.

Refs: #146
  • Loading branch information
hdevalke committed Sep 26, 2023
1 parent 9986150 commit 50cdbbe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cmd/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ impl CommitCommand {
}
Ok(cmd.status()?)
}

fn intend_to_add(&self) -> Result<ExitStatus, Error> {
let mut cmd = process::Command::new("git");
Ok(cmd.args(["add", "-N", "."]).status()?)
}

fn patch(&self) -> Result<ExitStatus, Error> {
let mut cmd = process::Command::new("git");
Ok(cmd.args(["add", "-p"]).status()?)
}
}

fn read_scope(
Expand Down Expand Up @@ -200,6 +210,8 @@ impl Dialog {

impl Command for CommitCommand {
fn exec(&self, config: Config) -> anyhow::Result<()> {
self.intend_to_add()?;
self.patch()?;
let r#type = match (
self.feat,
self.fix,
Expand Down

0 comments on commit 50cdbbe

Please sign in to comment.