Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 8, 2025

  • Add README documentation for rename command
  • Implement rename command with validation and tests
  • Move Name option from CommonOptions to RenameStackCommand (comment feedback)
  • Add test for stacks with same name across different remotes (comment feedback)
  • Use Questions.StackName instead of Questions.NewStackName for prompts (comment feedback)
  • Add early return for no stacks found to prevent errors (comment feedback)

Features

The new command provides:

  • --stack option to specify which stack to rename
  • --name option to specify the new stack name
  • Interactive prompts when options are not provided
  • Validation to prevent duplicate stack names for the same remote
  • Proper error handling for non-existent stacks
  • Early exit with appropriate message when no stacks exist for the repository

Usage Examples

# Rename with prompts
stack rename

# Rename specific stack with prompts for new name
stack rename --stack "feature-branch"

# Full command without prompts
stack rename --stack "old-name" --name "new-name"

Implementation Details

  • Added ChangeName method to the Stack record using immutable record pattern
  • Created RenameStackCommand and RenameStackCommandHandler following existing patterns
  • Added comprehensive validation to prevent naming conflicts
  • Registered command in dependency injection container
  • Updated CLI help and README documentation
  • Moved --name option to be command-specific rather than common
  • Uses consistent question text with existing Questions.StackName
  • Added early return with common log message when no stacks exist for repository

Testing

Added 9 comprehensive unit tests covering:

  • Interactive prompting scenarios
  • Validation edge cases (duplicate names, non-existent stacks)
  • Cross-remote name validation (allows same names across different remotes)
  • Error handling and success paths
  • No stacks found scenario

All 202 existing tests continue to pass, ensuring no regressions.

Fixes #363.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 8, 2025 08:49
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
Copilot AI changed the title [WIP] Add rename command Add rename command to change stack names Sep 8, 2025
Copilot AI requested a review from geofflamrock September 8, 2025 08:52
Required = false
};

public static Option<string?> Name { get; } = new Option<string?>("--name", "-n")
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot move this into the rename command directly, it shouldn't be common as it's not going to be used across multiple commands and is specific to the rename command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the Name option from CommonOptions to RenameStackCommand as a local static option since it's only used by the rename command. This follows the same pattern as other commands like NewStackCommand that define their own specific options. (035a2d5)

…validation

Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
throw new InvalidOperationException("Stack not found.");
}

var newName = await inputProvider.Text(logger, Questions.NewStackName, inputs.Name, cancellationToken);
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot instead of using this new question, use the existing Questions.StackName. Do NOT change the question text of Questions.StackName, just use it here and fix any tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use Questions.StackName instead of Questions.NewStackName and updated all related tests. All 201 tests continue to pass. (82f290c)

…command prompts

Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
Copilot AI requested a review from geofflamrock September 8, 2025 09:33
@geofflamrock geofflamrock added the enhancement New feature or request label Sep 8, 2025
Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
@geofflamrock geofflamrock changed the title Add rename command to change stack names Add rename command Sep 9, 2025
@geofflamrock geofflamrock marked this pull request as ready for review September 9, 2025 09:35
@geofflamrock geofflamrock enabled auto-merge (squash) September 9, 2025 09:36
@geofflamrock geofflamrock merged commit c1d572a into main Sep 9, 2025
8 checks passed
@geofflamrock geofflamrock deleted the copilot/fix-363 branch September 9, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rename command

2 participants