-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Introduce --dry-run option to commands #42
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,8 @@ protected function configure(): void | |
->setDescription('Update the extensions ext_emconf.php version to a specific version. Useful in CI environments') | ||
->addArgument('version', InputArgument::REQUIRED, 'The version to publish, e.g. 1.2.3. Must have three digits.') | ||
->addOption('path', '', InputOption::VALUE_OPTIONAL, 'Path to the extension folder', getcwd() ?: './') | ||
->addOption('no-docs', '', InputOption::VALUE_OPTIONAL, 'Disable version update in documentation settings', false); | ||
->addOption('no-docs', '', InputOption::VALUE_OPTIONAL, 'Disable version update in documentation settings', false) | ||
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
|
@@ -58,6 +59,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
return 1; | ||
} | ||
|
||
$dryRun = ($input->getOption('dry-run') === true); | ||
|
||
$emConfFile = rtrim($path, '/') . '/ext_emconf.php'; | ||
if (!file_exists($emConfFile)) { | ||
$io->error(sprintf('No \'ext_emconf.php\' found in the given path %s.', $path)); | ||
|
@@ -66,11 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
|
||
$versionReplacer = new VersionReplacer($version); | ||
|
||
try { | ||
$versionReplacer->setVersion($emConfFile, self::EMCONF_PATTERN); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while setting the ext_emconf.php version to %s.', $version)); | ||
return 1; | ||
if (!$dryRun) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just do an early return above L:71? There is nothing to do below, in case this is a dry run. Would make the change a bit smaller. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a note here and below. If we like to keep this output, no. |
||
try { | ||
$versionReplacer->setVersion($emConfFile, self::EMCONF_PATTERN); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while setting the ext_emconf.php version to %s.', $version)); | ||
return 1; | ||
} | ||
} else { | ||
$io->note(sprintf('Would have set version in ext_emconf.php to %s, skipping', $version)); | ||
} | ||
|
||
if ($input->getOption('no-docs') === null | ||
|
@@ -90,18 +97,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
return 0; | ||
} | ||
|
||
try { | ||
$versionReplacer->setVersion($documentationSettingsFile, self::DOCUMENTATION_RELEASE_PATTERN); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while updating the release number in %s', $documentationSettingsFile)); | ||
return 1; | ||
} | ||
|
||
try { | ||
$versionReplacer->setVersion($documentationSettingsFile, self::DOCUMENTATION_VERSION_PATTERN, 2); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while updating the version number in %s', $documentationSettingsFile)); | ||
return 1; | ||
if (!$dryRun) { | ||
try { | ||
$versionReplacer->setVersion($documentationSettingsFile, self::DOCUMENTATION_RELEASE_PATTERN); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while updating the release number in %s', $documentationSettingsFile)); | ||
return 1; | ||
} | ||
|
||
try { | ||
$versionReplacer->setVersion($documentationSettingsFile, self::DOCUMENTATION_VERSION_PATTERN, 2); | ||
} catch (\InvalidArgumentException $e) { | ||
$io->error(sprintf('An error occurred while updating the version number in %s', $documentationSettingsFile)); | ||
return 1; | ||
} | ||
} else { | ||
$io->note(sprintf('Would have set version in Documentation/Settings.cfg to %s, skipping', $version)); | ||
} | ||
|
||
return 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should output the command name instead, not sure....