From 2d44baa31caccb73c085432a5b449dd53adb82c9 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:50:25 +0100 Subject: [PATCH] FEATURE: Indicate if a rebase had conflicts --- .../W6-WorkspaceRebasing/01-BasicFeatures.feature | 8 ++++++++ .../03-RebasingWithConflictingChanges.feature | 8 ++++++++ .../Classes/Feature/WorkspaceCommandHandler.php | 2 ++ .../Feature/WorkspaceRebase/Event/WorkspaceWasRebased.php | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/01-BasicFeatures.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/01-BasicFeatures.feature index e080cf4d6bb..c72aa1f5c6c 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/01-BasicFeatures.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/01-BasicFeatures.feature @@ -62,6 +62,14 @@ Feature: Rebasing with no conflict | rebaseErrorHandlingStrategy | "force" | Then I expect the content stream "user-cs-identifier" to not exist + Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test" + And event at index 1 is of type "WorkspaceWasRebased" with payload: + | Key | Expected | + | workspaceName | "user-test" | + | newContentStreamId | "user-cs-rebased" | + | previousContentStreamId | "user-cs-identifier" | + | hadConflicts | false | + When I am in workspace "user-test" and dimension space point {} Then I expect node aggregate identifier "sir-david-nodenborough" to lead to node user-cs-rebased;sir-david-nodenborough;{} diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/03-RebasingWithConflictingChanges.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/03-RebasingWithConflictingChanges.feature index 7f30b4c68af..a12eb8316cb 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/03-RebasingWithConflictingChanges.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/W6-WorkspaceRebasing/03-RebasingWithConflictingChanges.feature @@ -179,6 +179,14 @@ Feature: Workspace rebasing - conflicting changes | rebasedContentStreamId | "user-cs-identifier-rebased" | | rebaseErrorHandlingStrategy | "force" | + Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-ws" + And event at index 1 is of type "WorkspaceWasRebased" with payload: + | Key | Expected | + | workspaceName | "user-ws" | + | newContentStreamId | "user-cs-identifier-rebased" | + | previousContentStreamId | "user-cs-identifier" | + | hadConflicts | true | + Then I expect the content stream "user-cs-identifier" to not exist Then I expect the content stream "user-cs-identifier-rebased" to exist diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index abb65c4c824..e7262f7b6e5 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -288,6 +288,7 @@ private function rebaseWorkspaceWithoutChanges( $workspace->workspaceName, $newContentStreamId, $workspace->currentContentStreamId, + hadConflicts: false ), ), ExpectedVersion::ANY() @@ -404,6 +405,7 @@ static function ($handle) use ($rebaseableCommands): void { $command->workspaceName, $command->rebasedContentStreamId, $workspace->currentContentStreamId, + hadConflicts: $commandSimulator->hasConflicts() ), ), ExpectedVersion::ANY() diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceRebase/Event/WorkspaceWasRebased.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceRebase/Event/WorkspaceWasRebased.php index 263f9e418c6..4156c1c08b6 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceRebase/Event/WorkspaceWasRebased.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceRebase/Event/WorkspaceWasRebased.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\EventStore\EventInterface; use Neos\ContentRepository\Core\Feature\Common\EmbedsWorkspaceName; +use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Dto\RebaseErrorHandlingStrategy; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; @@ -34,6 +35,10 @@ public function __construct( * The old content stream ID (which is not active anymore now) */ public ContentStreamId $previousContentStreamId, + /** + * Indicates if all events in the workspace were kept or if failing changes were discarded {@see RebaseErrorHandlingStrategy::STRATEGY_FORCE} + */ + public bool $hadConflicts ) { } @@ -48,6 +53,7 @@ public static function fromArray(array $values): self WorkspaceName::fromString($values['workspaceName']), ContentStreamId::fromString($values['newContentStreamId']), ContentStreamId::fromString($values['previousContentStreamId']), + $values['hadConflicts'] ?? false ); }