Skip to content

Commit 047f527

Browse files
committed
Return a success (zero) exit code from self:update if there is no update
Closes #1135
1 parent 2f94f16 commit 047f527

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/Command/CommandBase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ protected function checkUpdates()
336336

337337
try {
338338
$newVersion = $cliUpdater->update(null, $currentVersion);
339+
if ($newVersion === '') {
340+
return;
341+
}
339342
} catch (\RuntimeException $e) {
340343
if (strpos($e->getMessage(), 'Failed to download') !== false) {
341344
$this->stdErr->writeln('<error>' . $e->getMessage() . '</error>');

src/Command/Self/SelfUpdateCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
3434
$cliUpdater->setTimeout($input->getOption('timeout'));
3535

3636
$result = $cliUpdater->update($manifestUrl, $currentVersion);
37+
if ($result === '') {
38+
return 0;
39+
}
3740
if ($result === false) {
3841
return 1;
3942
}

src/Service/SelfUpdater.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function setAllowMajor($allowMajor = true)
8080
* @param string|null $currentVersion
8181
*
8282
* @return false|string
83-
* The new version number, or false if there was no update.
83+
* The new version number, or an empty string if there was no update, or false on error.
8484
*/
8585
public function update($manifestUrl = null, $currentVersion = null)
8686
{
@@ -124,7 +124,7 @@ public function update($manifestUrl = null, $currentVersion = null)
124124

125125
if (!$updater->hasUpdate()) {
126126
$this->stdErr->writeln('No updates found');
127-
return false;
127+
return '';
128128
}
129129

130130
$newVersionString = $updater->getNewVersion();

0 commit comments

Comments
 (0)