Skip to content

Commit

Permalink
feat: add tag prefix and suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocesarato committed Jan 28, 2021
1 parent 323a5c0 commit 469f166
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');

Expand Down
42 changes: 42 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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']);
}

/**
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 469f166

Please sign in to comment.