mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Handled tag conflict from rename tag action
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user