Skip to content

Commit

Permalink
feat(config): add bump package setting
Browse files Browse the repository at this point in the history
Ref: #11
  • Loading branch information
Marco Cesarato committed Apr 15, 2021
1 parent 9ecd9eb commit 343dd6e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,22 @@ public function generate(InputInterface $input, SymfonyStyle $output): int
$changelogNew .= $this->getMarkdownChanges($changes);
}
$filesToCommit = [$file];
foreach ($packageBumps as $packageBump) {
try {
/**
* @var Bump
*/
$bumper = new $packageBump($root);
if ($bumper->exists()) {
$bumper->setVersion($newVersion);
$bumper->save();
$filesToCommit[] = $bumper->getFilePath();

if ($this->config->isBumpPackage()) {
foreach ($packageBumps as $packageBump) {
try {
/**
* @var Bump
*/
$bumper = new $packageBump($root);
if ($bumper->exists()) {
$bumper->setVersion($newVersion);
$bumper->save();
$filesToCommit[] = $bumper->getFilePath();
}
} catch (Exception $e) {
$output->error('An error occurred bumping package version: ' . $e->getMessage());
}
} catch (Exception $e) {
$output->error('An error occurred bumping package version: ' . $e->getMessage());
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class Configuration
*/
protected $types = [];

/**
* Bump package.
*
* @var bool
*/
protected $bumpPackage = true;

/**
* Ignore message commit patterns.
*
Expand Down Expand Up @@ -263,6 +270,7 @@ public function fromArray(array $array)
'path' => $this->getPath(),
'preset' => $this->getPreset(),
'types' => [],
'bumpPackage' => $this->isBumpPackage(),
'ignoreTypes' => $this->getIgnoreTypes(),
'ignorePatterns' => $this->getIgnorePatterns(),
'tagPrefix' => $this->getTagPrefix(),
Expand Down Expand Up @@ -317,6 +325,8 @@ public function fromArray(array $array)
->setIgnorePatterns($params['ignorePatterns'])
->setIgnoreTypes($params['ignoreTypes'])
->setTypes($params['preset'])
// Bump Package
->setBumpPackage($params['bumpPackage'])
// Document
->setHeaderTitle($params['headerTitle'])
->setHeaderDescription($params['headerDescription'])
Expand Down Expand Up @@ -790,6 +800,18 @@ public function setPostRun($postRun): self
return $this;
}

public function isBumpPackage(): bool
{
return $this->bumpPackage;
}

public function setBumpPackage(bool $bumpPackage): Configuration
{
$this->bumpPackage = $bumpPackage;

return $this;
}

/**
* Validate settings.
*
Expand Down

0 comments on commit 343dd6e

Please sign in to comment.