Add output to git update in update script

This commit is contained in:
DariusIII
2016-05-12 22:18:18 +02:00
parent 8d7a806e8d
commit 6cdce48c33
6 changed files with 55 additions and 13 deletions
+2
View File
@@ -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
+30 -12
View File
@@ -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);
}
+8
View File
@@ -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) {
+3
View File
@@ -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",
+11
View File
@@ -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
+1 -1
View File
@@ -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),