Skip to content

Commit

Permalink
TASK: Inline ConflictsBuilder to better document deduplication logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 28, 2024
1 parent 15c13ab commit 36a5de7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 58 deletions.
7 changes: 1 addition & 6 deletions Classes/Application/Shared/Conflicts.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@

public function __construct(Conflict ...$items)
{
$this->items = $items;
}

public static function builder(): ConflictsBuilder
{
return new ConflictsBuilder();
$this->items = array_values($items);
}

public function jsonSerialize(): mixed
Expand Down
49 changes: 0 additions & 49 deletions Classes/Application/Shared/ConflictsBuilder.php

This file was deleted.

11 changes: 8 additions & 3 deletions Classes/Infrastructure/ContentRepository/ConflictsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Utility\Algorithms;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Ui\Application\Shared\Conflict;
Expand Down Expand Up @@ -76,14 +77,18 @@ public function __construct(
public function fromWorkspaceRebaseFailed(
WorkspaceRebaseFailed $workspaceRebaseFailed
): Conflicts {
$conflictsBuilder = Conflicts::builder();
/** @var array<string,Conflict> */
$conflictsByKey = [];

foreach ($workspaceRebaseFailed->commandsThatFailedDuringRebase as $commandThatFailedDuringRebase) {
$conflict = $this->createConflictFromCommandThatFailedDuringRebase($commandThatFailedDuringRebase);
$conflictsBuilder->addConflict($conflict);
if (array_key_exists($conflict->key, $conflictsByKey)) {
// deduplicate if the conflict affects the same node
$conflictsByKey[$conflict->key] = $conflict;
}
}

return $conflictsBuilder->build();
return new Conflicts(...$conflictsByKey);
}

private function createConflictFromCommandThatFailedDuringRebase(
Expand Down

0 comments on commit 36a5de7

Please sign in to comment.