mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 09:18:54 +00:00
02ad342bac
[ci skip] [skip ci]
70 lines
1.4 KiB
PHP
70 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Extensions\util\Git;
|
|
use Blacklight\Tmux;
|
|
use Illuminate\Console\Command;
|
|
|
|
class UpdateNNTmuxGit extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'nntmux:git';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Update NNTmux from git repository';
|
|
|
|
/**
|
|
* @var \app\extensions\util\Git object.
|
|
*/
|
|
protected $git;
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* @throws \Cz\Git\GitException
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->initialiseGit();
|
|
|
|
$wasRunning = false;
|
|
|
|
if ((new Tmux())->isRunning() === true) {
|
|
$wasRunning = true;
|
|
$this->call('tmux-ui:stop', ['--kill' => true]);
|
|
}
|
|
$this->info('Getting changes from Github');
|
|
$result = $this->git->gitPull();
|
|
$this->info($result[2]);
|
|
|
|
if ($wasRunning === true) {
|
|
$this->call('tmux-ui:start');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @throws \Cz\Git\GitException
|
|
*/
|
|
protected function initialiseGit()
|
|
{
|
|
if (! ($this->git instanceof Git)) {
|
|
$this->git = new Git();
|
|
}
|
|
}
|
|
}
|