Skip to content

Commit

Permalink
fix: Normalize version number before testing for available update
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Aug 3, 2022
1 parent 1aa63fe commit 7ca6032
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 1 addition & 6 deletions bin/phab
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ $dispatcher = $container->get(EventDispatcher::class);
$application->setDispatcher($dispatcher);
SelfUpdateCommand::registerListener($dispatcher);

$version = '@git_tag@';
if ($version[0] == '@') {
$version = Utilities::FALLBACK_VERSION;
}

$application->setVersion($version);
$application->setVersion(Utilities::FALLBACK_VERSION);
$application->setName('phabalicious');
$application->setDefaultCommand('list');
PluginDiscovery::discoverFromFabfile($container, $output);
Expand Down
9 changes: 7 additions & 2 deletions src/Command/SelfUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public function __construct(ConfigurationService $configuration, $name = null)
{
$this->configuration = $configuration;

parent::__construct('phab', Utilities::FALLBACK_VERSION, 'factorial-io/phabalicious');
$version_parser = new VersionParser();
$version = $version_parser->normalize(Utilities::FALLBACK_VERSION);

parent::__construct('phab', $version, 'factorial-io/phabalicious');
}

public function getConfiguration(): ConfigurationService
Expand Down Expand Up @@ -72,14 +75,16 @@ public function isUpdateAvailable()
{
try {
$version = $this->getApplication()->getVersion();
$version_parser = new VersionParser();
$version = $version_parser->normalize($version);
$preview =
(stripos($version, 'alpha') !== false) ||
(stripos($version, 'beta') !== false);


$latest = $this->getLatestReleaseFromGithub(['preview' => $preview])['version'];

$update_available = ($latest && Comparator::greaterThan($latest, $this->currentVersion));
$update_available = ($latest && Comparator::greaterThan($latest, $version));
$this->configuration->getLogger()->debug(sprintf(
'Version-Check: current: %s, latest on remote: %s, check for preview: %s, update available: %s',
$version,
Expand Down

0 comments on commit 7ca6032

Please sign in to comment.