Skip to content
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

Add option to run bump after update #11942

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

carlos-granados
Copy link
Contributor

@carlos-granados carlos-granados commented Apr 22, 2024

  • Adds a new bump-after-update config parameter
  • Adds a new bump-after-update option to the update command

If the bump-after-update config parameter is set or the bump-after-update option is passed to the update command, it will run the bump command after finishing the update. This command will only be run if the update finishes successfully

If the config parameter or the option are set to dev or no-dev then only the corresponding dependencies will be bumped.

The dry-run option passed to the update command will also be used for the bump command

If any packages are listed in the update command, this same package list will be used by the bump command.

Includes updates to the documentation and new tests

Fixes #11906

@carlos-granados carlos-granados force-pushed the add-bump-after-update-option branch 2 times, most recently from 6903fb0 to cc20ff5 Compare April 22, 2024 12:11
@carlos-granados
Copy link
Contributor Author

I can see that the PHP 8.4 tests are failing but the failures seem unrelated to these changes and they also seem to happen in the main branch

@carlos-granados carlos-granados force-pushed the add-bump-after-update-option branch 2 times, most recently from 0d8312d to 0d9f1b9 Compare April 22, 2024 14:03
{
$this->initTempComposer($composerJson);

if ($createLock) {
Copy link
Contributor Author

@carlos-granados carlos-granados Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bump command needs that a lock file exists, so when testing the bump-after-update version we need to create one

Copy link
Member

@Seldaek Seldaek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, after a quick review just one comment but I'll need to take a closer look when I'm back at my desk :)

doc/06-config.md Outdated
@@ -476,4 +476,9 @@ throw, but you can set this config option to `["example.org"]` to allow using sv
URLs on that hostname. This is a better/safer alternative to disabling `secure-http`
altogether.

## bump-after-update

Defaults to false. If set to true, Composer will run the Bump command after running
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a string|bool that also accepts "no-dev" and "dev" as values to configure the *-only flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestion sounds good. I'll wait until you come back and are able to take a deeper look. If you still feel this is the way to go, I'll modify the PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please :) Definitely feel like this would be an improvement.

bool $noDevOnly,
bool $dryRun,
array $packagesFilter,
bool $calledFromUpdate = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unused and unnecessary?


if ($bumpAfterUpdate) {
if ($result === 0) {
$io->writeError('<info>Running Bump after Update.</info>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$io->writeError('<info>Running Bump after Update.</info>');
$io->writeError('<info>Bumping dependencies</info>');

Comment on lines 270 to 271
} else {
$io->writeError('<warning>Not running Bump after Update because the update command did not finish successfully.</warning>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed.

Suggested change
} else {
$io->writeError('<warning>Not running Bump after Update because the update command did not finish successfully.</warning>');

@Seldaek Seldaek added this to the 2.8 milestone Apr 28, 2024
@carlos-granados carlos-granados force-pushed the add-bump-after-update-option branch from 0d9f1b9 to 1d13727 Compare April 29, 2024 11:48
@carlos-granados carlos-granados requested a review from Seldaek April 29, 2024 11:48
@cafferata
Copy link
Contributor

Hi @Seldaek, is there a reason why this GitHub pull request was not receive a (re)review the past four months? Has this perhaps been lost sight of? No rush, I saw other GitHub pull requests being reviewed/merged. So I was wondering how this works within your available time. Of course an answer of no time/priority is also completely valid. ☺️

@Seldaek
Copy link
Member

Seldaek commented Sep 2, 2024

It's just targetting 2.8 and I was focused on shipping patch releases for 2.7 so far.. kinda buffering 2.8 PRs until I'm ready to work on those because once I branch it out then I need to merge 2.7 into 2.8 which is more work for me.

@lyrixx
Copy link
Contributor

lyrixx commented Sep 2, 2024

Oh, thanks for this PR. I had spare time, and decided to try to fix my issue. And I totally miss your PR :/
For the record, I had another approach, were I factorized the code in a new service: lyrixx@df8a25b

Copy link
Member

@Seldaek Seldaek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly found some minor wording style issues, and one minor edge case in the code, overall pretty solid PR thanks! And sorry for the delay :)

doc/03-cli.md Outdated Show resolved Hide resolved
doc/06-config.md Outdated Show resolved Hide resolved
res/composer-schema.json Outdated Show resolved Hide resolved
src/Composer/Command/BumpCommand.php Outdated Show resolved Hide resolved
src/Composer/Command/UpdateCommand.php Outdated Show resolved Hide resolved
src/Composer/Command/UpdateCommand.php Outdated Show resolved Hide resolved
@Seldaek Seldaek merged commit c8838f1 into composer:main Sep 18, 2024
20 checks passed
@@ -663,6 +663,10 @@
"type": ["boolean", "string"],
"description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
},
"bump-after-update": {
"type": ["string", "boolean"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use enum to restrict the supported strings

Bumping dependencies
<warning>Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users.</warning>
<warning>If your package is not a library, you can explicitly specify the "type" by using "composer config type project".</warning>
<warning>Alternatively you can use --dev-only to only bump dependencies within "require-dev".</warning>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this --dev-only option is confusing when running this as part of composer update instead of composer bump

@@ -85,6 +85,7 @@ protected function configure()
new InputOption('minimal-changes', 'm', InputOption::VALUE_NONE, 'During a partial update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).'),
new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
new InputOption('bump-after-update', null, InputOption::VALUE_OPTIONAL, 'Runs bump after performing the update.', false, ['dev', 'no-dev', 'all']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using InputOption::VALUE_OPTIONAL is confusing here, because it makes composer update --bump-after-update valid during argument validation, but this would still make it use the default value (i.e. false). This should probably be using VALUE_REQUIRED instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants