Skip to content

Commit

Permalink
Merge pull request #767 from getgrav/feature/fix-local-themes-with-sa…
Browse files Browse the repository at this point in the history
…me-name-as-gpm

Fix local themes with same folder name (slug) as a theme published on the GPM
  • Loading branch information
rhukster committed Apr 5, 2016
2 parents 5e85ac6 + ee37650 commit 3571663
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions system/src/Grav/Common/GPM/GPM.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function getUpdatablePlugins()
}

foreach ($this->installed['plugins'] as $slug => $plugin) {
if (!isset($repository[$slug]) || $plugin->symlink) {
if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) {
continue;
}

Expand Down Expand Up @@ -272,7 +272,7 @@ public function getUpdatableThemes()
}

foreach ($this->installed['themes'] as $slug => $plugin) {
if (!isset($repository[$slug]) || $plugin->symlink) {
if (!isset($repository[$slug]) || $plugin->symlink || !$plugin->version || $plugin->gpm === false) {
continue;
}

Expand Down
21 changes: 19 additions & 2 deletions system/src/Grav/Console/Gpm/VersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Yaml\Yaml;

/**
* Class VersionCommand
Expand Down Expand Up @@ -70,10 +71,26 @@ protected function serve()
}

} else {
// get currently installed version
$locator = \Grav\Common\Grav::instance()['locator'];
$blueprints_path = $locator->findResource('plugins://' . $package . DS . 'blueprints.yaml');
if (!file_exists($blueprints_path)) { // theme?
$blueprints_path = $locator->findResource('themes://' . $package . DS . 'blueprints.yaml');
if (!file_exists($blueprints_path)) {
continue;
}
}

$package_yaml = Yaml::parse(file_get_contents($blueprints_path));
$currentlyInstalledVersion = $package_yaml['version'];

if (!$currentlyInstalledVersion) {
continue;
}

$installed = $this->gpm->findPackage($package);
if ($installed) {
$name = $installed->name;
$version = $installed->version;

if ($this->gpm->isUpdatable($package)) {
$updatable = ' [updatable: v<green>' . $installed->available . '</green>]';
Expand All @@ -84,7 +101,7 @@ protected function serve()
$updatable = $updatable ?: '';

if ($installed || $package == 'grav') {
$this->output->writeln('You are running <white>' . $name . '</white> v<cyan>' . $version . '</cyan>' . $updatable);
$this->output->writeln('You are running <white>' . $name . '</white> v<cyan>' . $currentlyInstalledVersion . '</cyan>' . $updatable);
} else {
$this->output->writeln('Package <red>' . $package . '</red> not found');
}
Expand Down

0 comments on commit 3571663

Please sign in to comment.