Skip to content

Conversation

@geofflamrock
Copy link
Owner

Fixes an issue where trying to remove a branch when non-interactive would fail by adding options --remove-children and --move-children-to-parent.

@geofflamrock geofflamrock requested a review from Copilot July 29, 2025 11:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds command-line options to handle child branches when removing a branch in non-interactive mode. Previously, the command would fail in non-interactive scenarios when child branches existed because it couldn't prompt the user for the desired action.

  • Added --remove-children and --move-children-to-parent options to the remove branch command
  • Updated the command handler to use the provided option instead of prompting when specified
  • Added comprehensive test coverage for both new options

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Stack/Commands/Branch/RemoveBranchCommand.cs Added new command options and validation logic to prevent conflicting options
src/Stack.Tests/Commands/Branch/RemoveBranchCommandHandlerTests.cs Added test cases to verify the new options work correctly and bypass user prompts
README.md Updated documentation to include the new command options

Comment on lines +51 to 52
removeChildren ? RemoveBranchChildAction.RemoveChildren : moveChildrenToParent ? RemoveBranchChildAction.MoveChildrenToParent : null));
}
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nested ternary operator is difficult to read and maintain. Consider using an if-else statement or extracting this logic into a separate method to improve readability.

Suggested change
removeChildren ? RemoveBranchChildAction.RemoveChildren : moveChildrenToParent ? RemoveBranchChildAction.MoveChildrenToParent : null));
}
DetermineRemoveBranchChildAction(removeChildren, moveChildrenToParent)));
}
private static RemoveBranchChildAction? DetermineRemoveBranchChildAction(bool removeChildren, bool moveChildrenToParent)
{
if (removeChildren)
{
return RemoveBranchChildAction.RemoveChildren;
}
else if (moveChildrenToParent)
{
return RemoveBranchChildAction.MoveChildrenToParent;
}
else
{
return null;
}
}

Copilot uses AI. Check for mistakes.
@geofflamrock geofflamrock added the patch Increment the patch version when merged label Aug 2, 2025
@geofflamrock geofflamrock merged commit d8a3b04 into main Aug 2, 2025
16 checks passed
@geofflamrock geofflamrock deleted the remove-branch-child-action-non-interactive branch August 2, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants