Skip to content

Commit 344fa3f

Browse files
authored
Merge pull request #433 from nextcloud/fix/fix-version-option
Fix --version option
2 parents 121af7e + f3e2bcd commit 344fa3f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ tests/data
44
tests/vendor
55
vendor/symfony/console/Tests
66
vendor/symfony/debug/Tests
7-
/vendor-bin/**/vendor
7+
/vendor-bin/**/vendor
8+
.php-cs-fixer.cache

lib/CommandApplication.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
* @package NC\Updater
3333
*/
3434
class CommandApplication extends Application {
35+
public function __construct(string $name = 'update') {
36+
parent::__construct($name, UpdateCommand::getUpdaterVersion());
37+
}
38+
3539
/**
3640
* Gets the name of the command based on input.
3741
*

lib/UpdateCommand.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ protected function configure() {
6363
->addOption('no-backup', null, InputOption::VALUE_NONE, 'Skip backup of current Nextcloud version');
6464
}
6565

66-
protected function execute(InputInterface $input, OutputInterface $output) {
67-
$this->skipBackup = $input->getOption('no-backup');
68-
66+
public static function getUpdaterVersion(): string {
6967
if (class_exists('NC\Updater\Version')) {
7068
$versionClass = new Version();
71-
$version = $versionClass->get();
69+
return $versionClass->get();
7270
} else {
73-
$version = 'directly run from git checkout';
71+
return 'git';
7472
}
73+
}
74+
75+
protected function execute(InputInterface $input, OutputInterface $output) {
76+
$this->skipBackup = $input->getOption('no-backup');
77+
78+
$version = static::getUpdaterVersion();
7579
$output->writeln('Nextcloud Updater - version: ' . $version);
7680
$output->writeln('');
7781

updater.phar

191 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)