diff --git a/Changelog b/Changelog index 58267eb77..03abebd1b 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ 2016-05-12 DariusIII + * Upd: Add output to git update + * Fix: Fix minsize queries fail * Fix: Add/fix CouchPotato icons to themes. * Fix: Remove derefferer links from CouchPotato url in Gamma theme. * Fix: Fix nntmux_schema_fi for misc cats diff --git a/app/extensions/command/Update.php b/app/extensions/command/Update.php index 8c58e0aad..257c48556 100644 --- a/app/extensions/command/Update.php +++ b/app/extensions/command/Update.php @@ -73,45 +73,63 @@ class Update extends \app\extensions\console\Command { // TODO Add check to determine if the indexer or other scripts are running. Hopefully // also prevent web access. - $this->primary("Checking database version..."); + $this->out("Checking database version...", 'primary'); $versions = new Versions(['git' => ($this->git instanceof Git) ? $this->git : null]); $currentDb = $versions->getSQLPatchFromDB(); $currentXML = $versions->getSQLPatchFromFile(); + $this->out("Db: $currentDb,\tFile: $currentXML"); if ($currentDb < $currentXML) { $db = new DbUpdate(['backup' => false]); $db->processPatches(['safe' => false]); } else { - $this->out("Up to date."); + $this->out("Up to date.", 'info'); } } public function git() { + // TODO Add check to determine if the indexer or other scripts are running. Hopefully + // also prevent web access. $this->initialiseGit(); if (!in_array($this->git->getBranch(), $this->git->getBranchesMain())) { - $this->error("Not on the stable or dev branch! Refusing to update repository ;-)"); + $this->out("Not on the stable or dev branch! Refusing to update repository ;-)", 'error'); return; } - $this->git->run('pull'); + //return + $this->out($this->git->pull()); } public function nntmux() { try { - $this->git(); - $this->composer(); - $this->db(); + $output = $this->git(); + if ($output === 'Already up-to-date.') { + $this->out($output, 'info'); + } else { + $fail = $this->composer(); + if (!$fail) { + $fail = $this->db(); + if ($fail) { + $this->out('Db updating failed!!', 'error'); + return false; + } + } else { + $this->out('Composer failed to update!!', 'error'); + return false; + }; + } $smarty = new Smarty(); $cleared = $smarty->clearCompiledTemplate(); if ($cleared) { - $this->primary('The Smarty compiled template cache has been cleaned for you'); + $this->out('The Smarty compiled template cache has been cleaned for you', 'primary'); } else { - $this->primary('You should clear your Smarty compiled template cache at: ' . - NN_RES . "smarty" . DS . 'templates_c'); + $this->out('You should clear your Smarty compiled template cache at: ' . + NN_RES . "smarty" . DS . 'templates_c', + 'primary'); } } catch (\Exception $e) { $this->error($e->getMessage()); @@ -123,7 +141,7 @@ class Update extends \app\extensions\console\Command */ public function predb() { - $this->error('predb not available yet!'); + $this->out('predb not available yet!', 'error'); } public function run($command = null) @@ -158,7 +176,7 @@ class Update extends \app\extensions\console\Command if (in_array($this->gitBranch, $this->git->getBranchesStable())) { $command .= ' --no-dev'; } - $this->primary('Running composer install process...'); + $this->out('Running composer install process...', 'primary'); passthru($command); } diff --git a/app/extensions/console/Command.php b/app/extensions/console/Command.php index 8108c50f6..27f1a182e 100755 --- a/app/extensions/console/Command.php +++ b/app/extensions/console/Command.php @@ -34,6 +34,14 @@ class Command extends \lithium\console\Command require_once NN_ROOT . 'constants.php'; } + public function info($text) + { + if ($this->silent) { + return; + } + $this->out($text, 'info'); + } + public function primary($text) { if ($this->silent) { diff --git a/app/extensions/console/Response.php b/app/extensions/console/Response.php index ef62e6d1b..d2d0dec2b 100755 --- a/app/extensions/console/Response.php +++ b/app/extensions/console/Response.php @@ -309,6 +309,9 @@ class Response extends \lithium\console\Response 'gray' => "\033[37m", 'grey' => "\033[37m", 'hidden' => "\033[8m", + 'info' => "\033[35mInfo: ", // replace with updated version of: + // "\033[" . self::coloursForeground['purple'] . "mInfo: $text\033[0m" + // when we switch to PHP 5.6 'normal' => "\033[0m", 'primary' => "\033[38;5;010m", 'reset' => "\033[0m", diff --git a/app/extensions/util/Git.php b/app/extensions/util/Git.php index 99a0e1fb5..f7a004bbf 100644 --- a/app/extensions/util/Git.php +++ b/app/extensions/util/Git.php @@ -131,6 +131,17 @@ class Git extends \lithium\core\Object return $this->run("log $options"); } + public function pull(array $options = []) + { + $default = [ + 'branch' => $this->getBranch(), + 'remote' => 'origin', + ]; + $options += $default; + + return $this->repo->pull($options['remote'], $options['branch']); + } + /** * Run a git command in the git repository * Accepts a git command to run diff --git a/newznab/Releases.php b/newznab/Releases.php index 41c1a3441..7f8772186 100755 --- a/newznab/Releases.php +++ b/newznab/Releases.php @@ -227,7 +227,7 @@ class Releases LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id GROUP BY r.id - ORDER BY %7\$s %8\$s", + ORDER BY %8\$s %9\$s", NZB::NZB_ADDED, $this->showPasswords, $this->categorySQL($cat),