From 469f166f117478198d9fbdb55a4ea2b7f1d02ff3 Mon Sep 17 00:00:00 2001 From: Marco Cesarato Date: Thu, 28 Jan 2021 22:27:03 +0100 Subject: [PATCH] feat: add tag prefix and suffix --- src/Changelog.php | 5 +++-- src/Configuration.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Changelog.php b/src/Changelog.php index 92ea915..d021efe 100644 --- a/src/Changelog.php +++ b/src/Changelog.php @@ -347,9 +347,10 @@ public function generate(InputInterface $input, SymfonyStyle $output): int $output->success('Release committed!'); // Create tag if ($autoTag) { - $result = Repository::tag('v' . $newVersion); + $tag = $this->config->getTagPrefix() . $newVersion . $this->config->getTagSuffix(); + $result = Repository::tag($tag); if ($result !== false) { - $output->success("Release tagged with success! New version: v{$newVersion}"); + $output->success("Release tagged with success! New version: {$tag}"); } else { $output->error('An error occurred tagging the release!'); diff --git a/src/Configuration.php b/src/Configuration.php index 813c33e..cfd5f95 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -84,6 +84,20 @@ class Configuration */ public $ignoreTypes = ['build', 'chore', 'ci', 'docs', 'perf', 'refactor', 'revert', 'style', 'test']; + /** + * Tag prefix. + * + * @var string + */ + public $tagPrefix = 'v'; + + /** + * Tag suffix. + * + * @var string + */ + public $tagSuffix = ''; + /** * Constructor. */ @@ -128,6 +142,8 @@ public function fromArray(array $array) 'types' => [], 'ignoreTypes' => $this->getIgnoreTypes(), 'ignorePatterns' => $this->getIgnorePatterns(), + 'tagPrefix' => $this->getTagPrefix(), + 'tagSuffix' => $this->getTagSuffix(), ]; $params = array_replace_recursive($defaults, $array); @@ -160,6 +176,8 @@ public function fromArray(array $array) $this->setTypes($params['preset']); $this->setHeaderTitle($params['headerTitle']); $this->setHeaderDescription($params['headerDescription']); + $this->setTagPrefix($params['tagPrefix']); + $this->setTagSuffix($params['tagSuffix']); } /** @@ -333,4 +351,28 @@ public function setRoot(?string $root = null): Configuration return $this; } + + public function getTagPrefix(): string + { + return $this->tagPrefix; + } + + public function setTagPrefix(string $tagPrefix): Configuration + { + $this->tagPrefix = $tagPrefix; + + return $this; + } + + public function getTagSuffix(): string + { + return $this->tagSuffix; + } + + public function setTagSuffix(string $tagSuffix): Configuration + { + $this->tagSuffix = $tagSuffix; + + return $this; + } }