From 343dd6e47259c0190aa41cad5a42597df64a0d0d Mon Sep 17 00:00:00 2001 From: Marco Cesarato Date: Thu, 15 Apr 2021 09:37:56 +0200 Subject: [PATCH] feat(config): add bump package setting Ref: #11 --- src/Changelog.php | 27 +++++++++++++++------------ src/Configuration.php | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/Changelog.php b/src/Changelog.php index 44ac41c..d19d1b2 100644 --- a/src/Changelog.php +++ b/src/Changelog.php @@ -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()); } } diff --git a/src/Configuration.php b/src/Configuration.php index c7e1fe7..8859ecc 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -73,6 +73,13 @@ class Configuration */ protected $types = []; + /** + * Bump package. + * + * @var bool + */ + protected $bumpPackage = true; + /** * Ignore message commit patterns. * @@ -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(), @@ -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']) @@ -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. *