Handled tag conflict from rename tag action

This commit is contained in:
Alejandro Celaya
2019-12-06 21:03:22 +01:00
parent b9b3295b52
commit 05451e3d1a
4 changed files with 48 additions and 3 deletions

View File

@@ -8,8 +8,8 @@ use function sprintf;
class TagConflictException extends RuntimeException
{
public static function fromExistingTag(string $tag): self
public static function fromExistingTag(string $oldName, string $newName): self
{
return new self(sprintf('Tag with name %s already exists', $tag));
return new self(sprintf('You cannot rename tag %s to %s, because it already exists', $oldName, $newName));
}
}

View File

@@ -82,7 +82,7 @@ class TagService implements TagServiceInterface
$newNameExists = $newName !== $oldName && $repo->count(['name' => $newName]) > 0;
if ($newNameExists) {
throw TagConflictException::fromExistingTag($newName);
throw TagConflictException::fromExistingTag($oldName, $newName);
}
$tag->rename($newName);