Skip to content

Commit

Permalink
Fix UpdateVersion command stash flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Mar 26, 2024
1 parent 00c3e2a commit 337ce0f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Generator/Commands/UpdateVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

$ynCommit = strtolower(readline('Do you want to commit version-related file changes? [Y/n] '));
$commit = $ynCommit === 'y' || $ynCommit === 'yes';
if ($commit) {
exec('git stash --include-untracked');
}

$config = json_decode(file_get_contents(GENERATOR_CONFIG_FILE), true);
$config['version'] = $newVersion;
file_put_contents(GENERATOR_CONFIG_FILE, json_encode($config, JSON_PRETTY_PRINT)."\n");
Expand All @@ -56,13 +62,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
json_encode($composerConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n"
);

$ynCommit = strtolower(readline('Do you want to commit version-related file changes? [Y/n] '));
$commit = $ynCommit === 'y' || $ynCommit === 'yes';
if (! $commit) {
return 0;
}

exec('git stash --include-untracked');
$configFile = GENERATOR_CONFIG_FILE;
exec("git add $configFile $composerFile && git commit -m 'Update package version to $newVersion' && git stash pop");

Expand Down

0 comments on commit 337ce0f

Please sign in to comment.