Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-n, --name The name of the stack. Must be unique within the repository.
-s, --source-branch The source branch to use for the new stack. Defaults to the default branch for the repository.
Expand All @@ -188,6 +189,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
--json Output results as JSON.
-?, -h, --help Show help and usage information
Expand All @@ -203,6 +205,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
--json Output results as JSON.
-s, --stack The name of the stack.
Expand All @@ -221,6 +224,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-y, --yes Confirm the command without prompting.
Expand All @@ -237,6 +241,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-n, --name The new name for the stack.
Expand All @@ -255,6 +260,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
--rebase Use rebase when updating the stack. Overrides any setting in Git configuration.
Expand All @@ -272,6 +278,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-b, --branch The name of the branch.
-?, -h, --help Show help and usage information
Expand All @@ -287,6 +294,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-y, --yes Confirm the command without prompting.
Expand All @@ -303,6 +311,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-b, --branch The name of the branch.
Expand All @@ -320,6 +329,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-b, --branch The name of the branch.
Expand All @@ -337,6 +347,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-b, --branch The name of the branch.
Expand All @@ -358,6 +369,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-?, -h, --help Show help and usage information
Expand All @@ -373,6 +385,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
--max-batch-size The maximum number of branches to process at once. [default: 5]
Expand All @@ -390,6 +403,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
--max-batch-size The maximum number of branches to process at once. [default: 5]
Expand All @@ -412,6 +426,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-?, -h, --help Show help and usage information
Expand All @@ -427,6 +442,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-s, --stack The name of the stack.
-?, -h, --help Show help and usage information
Expand All @@ -444,6 +460,7 @@ Usage:

Options:
--working-dir The path to the directory containing the git repository. Defaults to the current directory.
--debug Show debug output.
--verbose Show verbose output.
-?, -h, --help Show help and usage information
```
30 changes: 20 additions & 10 deletions src/Stack.Tests/Commands/Branch/NewBranchCommandHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public async Task WhenNoInputsProvided_AsksForStackAndBranchAndParentBranch_Crea
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -37,7 +38,7 @@ public async Task WhenNoInputsProvided_AsksForStackAndBranchAndParentBranch_Crea
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
inputProvider.Text(Questions.BranchName, Arg.Any<CancellationToken>(), Arg.Any<string>()).Returns(newBranch);
Expand Down Expand Up @@ -72,6 +73,7 @@ public async Task WhenStackNameProvided_DoesNotAskForStackName_CreatesAndAddsBra
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -83,7 +85,7 @@ public async Task WhenStackNameProvided_DoesNotAskForStackName_CreatesAndAddsBra
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Text(Questions.BranchName, Arg.Any<CancellationToken>(), Arg.Any<string>()).Returns(newBranch);
inputProvider.Select(Questions.SelectParentBranch, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns(anotherBranch);
Expand Down Expand Up @@ -117,14 +119,15 @@ public async Task WhenOnlyOneStackExists_DoesNotAskForStackName_CreatesAndAddsBr
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch)
.WithBranch(branch => branch.WithName(anotherBranch)))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Text(Questions.BranchName, Arg.Any<CancellationToken>(), Arg.Any<string>()).Returns(newBranch);
inputProvider.Select(Questions.SelectParentBranch, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns(anotherBranch);
Expand Down Expand Up @@ -157,6 +160,7 @@ public async Task WhenStackNameProvided_ButStackDoesNotExist_Throws()
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -168,7 +172,7 @@ public async Task WhenStackNameProvided_ButStackDoesNotExist_Throws()
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

gitClient.GetRemoteUri().Returns(remoteUri);
gitClient.GetCurrentBranch().Returns(sourceBranch);
Expand All @@ -194,6 +198,7 @@ public async Task WhenBranchNameProvided_DoesNotAskForBranchName_CreatesAndAddsB
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -205,7 +210,7 @@ public async Task WhenBranchNameProvided_DoesNotAskForBranchName_CreatesAndAddsB
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
inputProvider.Select(Questions.SelectParentBranch, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns(anotherBranch);
Expand Down Expand Up @@ -238,6 +243,7 @@ public async Task WhenBranchNameProvided_ButBranchAlreadyExistLocally_Throws()
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -248,7 +254,7 @@ public async Task WhenBranchNameProvided_ButBranchAlreadyExistLocally_Throws()
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
gitClient.GetRemoteUri().Returns(remoteUri);
Expand Down Expand Up @@ -276,6 +282,7 @@ public async Task WhenBranchNameProvided_ButBranchAlreadyExistsInStack_Throws()
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -288,7 +295,7 @@ public async Task WhenBranchNameProvided_ButBranchAlreadyExistsInStack_Throws()
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
gitClient.GetRemoteUri().Returns(remoteUri);
Expand All @@ -315,6 +322,7 @@ public async Task WhenPushToTheRemoteFails_StillCreatesTheBranchLocallyAndAddsIt
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -326,7 +334,7 @@ public async Task WhenPushToTheRemoteFails_StillCreatesTheBranchLocallyAndAddsIt
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

gitClient.When(gc => gc.PushNewBranch(newBranch)).Do(_ => { throw new Exception("Failed to push branch"); });

Expand Down Expand Up @@ -365,6 +373,7 @@ public async Task WhenParentBranchNotProvided_AsksForParentBranch_CreatesNewBran
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -376,7 +385,7 @@ public async Task WhenParentBranchNotProvided_AsksForParentBranch_CreatesNewBran
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
inputProvider.Text(Questions.BranchName, Arg.Any<CancellationToken>(), Arg.Any<string>()).Returns(newBranch);
Expand Down Expand Up @@ -412,6 +421,7 @@ public async Task WhenParentBranchProvided_DoesNotAskForParentBranch_CreatesNewB
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<NewBranchCommandHandler>(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var displayProvider = new TestDisplayProvider(testOutputHelper);
var stackConfig = new TestStackConfigBuilder()
.WithStack(stack => stack
.WithName("Stack1")
Expand All @@ -423,7 +433,7 @@ public async Task WhenParentBranchProvided_DoesNotAskForParentBranch_CreatesNewB
.WithRemoteUri(remoteUri)
.WithSourceBranch(sourceBranch))
.Build();
var handler = new NewBranchCommandHandler(inputProvider, logger, gitClient, stackConfig);
var handler = new NewBranchCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig);

inputProvider.Select(Questions.SelectStack, Arg.Any<string[]>(), Arg.Any<CancellationToken>()).Returns("Stack1");
inputProvider.Text(Questions.BranchName, Arg.Any<CancellationToken>(), Arg.Any<string>()).Returns(newBranch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public async Task WhenNoStackNameIsProvided_AsksForStack_PullsChangesForTheCorre
.Build();
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<PullStackCommandHandler>(testOutputHelper);
var displayProvider = new TestDisplayProvider(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var stackActions = Substitute.For<IStackActions>();
var handler = new PullStackCommandHandler(inputProvider, logger, gitClient, stackConfig, stackActions);
var handler = new PullStackCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig, stackActions);

gitClient.GetRemoteUri().Returns(remoteUri);
gitClient.GetCurrentBranch().Returns(branch1);
Expand Down Expand Up @@ -76,9 +77,10 @@ public async Task WhenNameIsProvided_DoesNotAskForName_PullsChangesForTheCorrect
.Build();
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<PullStackCommandHandler>(testOutputHelper);
var displayProvider = new TestDisplayProvider(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var stackActions = Substitute.For<IStackActions>();
var handler = new PullStackCommandHandler(inputProvider, logger, gitClient, stackConfig, stackActions);
var handler = new PullStackCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig, stackActions);

gitClient.GetRemoteUri().Returns(remoteUri);
gitClient.GetCurrentBranch().Returns(branch1);
Expand Down Expand Up @@ -116,9 +118,10 @@ public async Task WhenNameIsProvided_ButStackDoesNotExist_Throws()
.Build();
var inputProvider = Substitute.For<IInputProvider>();
var logger = XUnitLogger.CreateLogger<PullStackCommandHandler>(testOutputHelper);
var displayProvider = new TestDisplayProvider(testOutputHelper);
var gitClient = Substitute.For<IGitClient>();
var stackActions = Substitute.For<IStackActions>();
var handler = new PullStackCommandHandler(inputProvider, logger, gitClient, stackConfig, stackActions);
var handler = new PullStackCommandHandler(inputProvider, logger, displayProvider, gitClient, stackConfig, stackActions);

gitClient.GetRemoteUri().Returns(remoteUri);
gitClient.GetCurrentBranch().Returns(branch1);
Expand Down
Loading
Loading