Skip to content

Conversation

@geofflamrock
Copy link
Owner

@geofflamrock geofflamrock commented Oct 14, 2025

Removes Remote Uri from the core stack domain and introduces separate types for the config file.

Part of a series:

@geofflamrock geofflamrock added the internal Changes only affect the internal API label Oct 14, 2025
@geofflamrock geofflamrock force-pushed the remove-remote-uri-from-stack-model branch from c6e5d80 to 4d8bc07 Compare October 14, 2025 21:33
@geofflamrock geofflamrock force-pushed the move-stack-classes-around branch from 5d36139 to 1a9cf92 Compare October 14, 2025 21:33
@geofflamrock geofflamrock force-pushed the remove-remote-uri-from-stack-model branch 2 times, most recently from 8d06d1f to 46d4572 Compare October 14, 2025 21:40
var stacks2 = repository.GetStacks();
var stack2Model = new Model.Stack("Stack2", "main", []);
repository.AddStack(stack2Model);
repository.RemoveStack(stack2Model);
Copy link
Owner Author

Choose a reason for hiding this comment

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

Need to check actual stacks or save here

await Task.CompletedTask;

var configPath = stackConfig.GetConfigPath();
var configPath = dataStore.GetConfigPath();
Copy link
Owner Author

Choose a reason for hiding this comment

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

Should change this to be an Open method or something similar.

namespace Stack.Persistence;

public record StackData(List<Model.Stack> Stacks);
public record StackDataItem(string Name, string RemoteUri, string SourceBranch, List<StackBranchItem> Branches);
Copy link
Owner Author

@geofflamrock geofflamrock Oct 14, 2025

Choose a reason for hiding this comment

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

Might want better names than these

Base automatically changed from move-stack-classes-around to main October 15, 2025 06:15
@geofflamrock geofflamrock force-pushed the remove-remote-uri-from-stack-model branch from a8ac267 to 4d4ca5e Compare October 15, 2025 06:16
@geofflamrock geofflamrock requested a review from Copilot October 17, 2025 07:54
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 refactors the stack persistence layer by removing remote URI from the core stack domain model and introducing separate types for configuration file persistence. The refactor separates concerns between the domain model (which no longer includes remote URI) and the data storage layer (which maintains remote URI for repository filtering).

Key changes:

  • Removed RemoteUri parameter from core Stack model
  • Introduced StackDataItem and StackBranchItem as separate persistence types
  • Added mapping logic between domain and persistence models in StackRepository
  • Renamed IStackConfig/FileStackConfig to IStackDataStore/FileStackDataStore

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Stack/Model/Stack.cs Removed RemoteUri parameter from Stack record
src/Stack/Persistence/StackRepository.cs Added mapping between domain and persistence models, renamed dependencies
src/Stack/Persistence/FileStackDataStore.cs Renamed from FileStackConfig, updated to work with new StackDataItem types
src/Stack/Infrastructure/HostApplicationBuilderExtensions.cs Updated DI registration to use new interface name
src/Stack/Commands/Stack/NewStackCommand.cs Updated to create Stack without RemoteUri
src/Stack/Commands/Config/OpenConfigCommand.cs Updated to use new IStackDataStore interface
Test files Updated all test files to remove RemoteUri from Stack constructors and use new types

{
stackData.Value.Stacks.Remove(stack);
var remoteUri = GetRemoteUri();
var stackToRemove = stackData.Value.Stacks.FirstOrDefault(s => s.Name == stack.Name && s.RemoteUri == remoteUri);
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

Consider using StringComparison.OrdinalIgnoreCase for the RemoteUri comparison to maintain consistency with the filtering logic in GetStacks() method.

Suggested change
var stackToRemove = stackData.Value.Stacks.FirstOrDefault(s => s.Name == stack.Name && s.RemoteUri == remoteUri);
var stackToRemove = stackData.Value.Stacks.FirstOrDefault(s => s.Name == stack.Name && s.RemoteUri.Equals(remoteUri, StringComparison.OrdinalIgnoreCase));

Copilot uses AI. Check for mistakes.
var stackToRemove = stackData.Value.Stacks.FirstOrDefault(s => s.Name == stack.Name && s.RemoteUri == remoteUri);
if (stackToRemove == null)
{
throw new InvalidOperationException($"Stack '{stack.Name}' does not exist in the current repository.");
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

The error message mentions 'current repository' but the actual issue could be either that the stack doesn't exist or that it exists but for a different remote URI. Consider making the error message more specific about which condition failed.

Suggested change
throw new InvalidOperationException($"Stack '{stack.Name}' does not exist in the current repository.");
// Check if stack exists for a different remote URI
var stackWithName = stackData.Value.Stacks.FirstOrDefault(s => s.Name == stack.Name);
if (stackWithName != null)
{
throw new InvalidOperationException(
$"Stack '{stack.Name}' exists, but for a different remote URI ('{stackWithName.RemoteUri}'). " +
$"Current remote URI: '{remoteUri}'.");
}
else
{
throw new InvalidOperationException($"Stack '{stack.Name}' does not exist.");
}

Copilot uses AI. Check for mistakes.
@geofflamrock geofflamrock enabled auto-merge (squash) October 20, 2025 08:55
@geofflamrock geofflamrock merged commit d3b25b4 into main Oct 20, 2025
9 of 10 checks passed
@geofflamrock geofflamrock deleted the remove-remote-uri-from-stack-model branch October 20, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Changes only affect the internal API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants