Skip to content

Commit

Permalink
fix(create): check if the working tree is clean before creating branch (
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir authored Oct 24, 2024
1 parent 2b0a59c commit 53e4476
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/subcommands/local/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ impl CreateCmd {
None => inquire::Text::new("Name of new branch:").prompt()?,
};

// Check if the working tree is clean.
if !ctx.repository.is_working_tree_clean()? {
return Err(crate::errors::StError::WorkingTreeDirty);
}

// Attempt to create the new branch.
ctx.repository
.branch(&new_branch_name, &current_branch_head, false)?;
Expand Down

0 comments on commit 53e4476

Please sign in to comment.