Skip to content

Commit

Permalink
feat: New option: Do not update CHANGELOG if no commits found.
Browse files Browse the repository at this point in the history
  • Loading branch information
william-suppo committed Nov 25, 2022
1 parent 8cb6ec0 commit 00a81ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ Options:
--history Generate the entire history of changes of all releases
--no-verify Bypasses the pre-commit and commit-msg hooks
--no-tag Disable release auto tagging
--no-change-without-commits Do not apply change if no commits
--annotate-tag[=ANNOTATE-TAG] Make an unsigned, annotated tag object once changelog is generated [default: false]
--merged Only include commits whose tips are reachable from HEAD
-h, --help Display help for the given command. When no command is given display help for the changelog command
Expand Down
7 changes: 7 additions & 0 deletions src/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function generate(string $root, InputInterface $input, SymfonyStyle $outp
$autoCommit = $input->getOption('commit'); // Commit once changelog is generated
$autoCommitAll = $input->getOption('commit-all'); // Commit all changes once changelog is generated
$autoTag = !($input->getOption('no-tag') || $this->config->skipTag()); // Tag release once is committed
$noChangeWithoutCommits = $input->getOption('no-change-without-commits');
$annotateTag = $input->getOption('annotate-tag');
$amend = $input->getOption('amend'); // Amend commit
$hooks = !$input->getOption('no-verify'); // Verify git hooks
Expand Down Expand Up @@ -388,6 +389,12 @@ public function generate(string $root, InputInterface $input, SymfonyStyle $outp
}
$filesToCommit = [$file];

if (isset($commits) && ! count($commits) && $noChangeWithoutCommits) {
$output->warning('No commits since last version.');

return 0; // Command::SUCCESS;
}

if ($this->config->isPackageBump()) {
foreach ($packageBumps as $packageBump) {
try {
Expand Down
1 change: 1 addition & 0 deletions src/DefaultCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected function configure()
new InputOption('history', null, InputOption::VALUE_NONE, 'Generate the entire history of changes of all releases'),
new InputOption('no-verify', null, InputOption::VALUE_NONE, 'Bypasses the pre-commit and commit-msg hooks'),
new InputOption('no-tag', null, InputOption::VALUE_NONE, 'Disable release auto tagging'),
new InputOption('no-change-without-commits', null, InputOption::VALUE_NONE, 'Do not apply change if no commits'),
new InputOption('annotate-tag', null, InputOption::VALUE_OPTIONAL, 'Make an unsigned, annotated tag object once changelog is generated', false),
new InputOption('merged', null, InputOption::VALUE_NONE, 'Only include commits whose tips are reachable from HEAD'),
]);
Expand Down

0 comments on commit 00a81ee

Please sign in to comment.