Skip to content

Commit

Permalink
refactor: repair formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgrayson committed Feb 5, 2024
1 parent 8a38c12 commit 1419e6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/cmd/branch/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ pub(super) fn command() -> clap::Command {
}

pub(super) fn dispatch(repo: &gix::Repository, matches: &clap::ArgMatches) -> Result<()> {
let (target_branch, target_branchname) = if let Some(branch_loc) = matches.get_one::<BranchLocator>("branch-any") {
let branch = branch_loc.resolve(repo)?;
let branchname = branch.get_branch_partial_name()?;
(branch, branchname)
let target_branch = if let Some(branch_loc) = matches.get_one::<BranchLocator>("branch-any") {
branch_loc.resolve(repo)?
} else if let Ok(branch) = repo.get_current_branch() {
let branchname = branch.get_branch_partial_name()?;
(branch, branchname)
branch
} else {
return Err(anyhow!("no target branch specified and no current branch"));
};

let target_branchname = target_branch.get_branch_partial_name()?;
let current_branch = repo.get_current_branch().ok();
let current_branchname = current_branch
.as_ref()
Expand Down
8 changes: 6 additions & 2 deletions src/stack/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ impl<'repo> Stack<'repo> {
// It is ok if the StGit-specific config section does not exist.
let mut local_config_file = repo.local_config_file()?;
let section = format!("{branch_name}.stgit");
if local_config_file.remove_section("branch", Some(section.as_bytes().into())).is_some() {
repo.write_local_config(local_config_file).context("writing local config")?;
if local_config_file
.remove_section("branch", Some(section.as_bytes().into()))
.is_some()
{
repo.write_local_config(local_config_file)
.context("writing local config")?;
}

Ok(())
Expand Down

0 comments on commit 1419e6f

Please sign in to comment.