mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-23 08:02:15 +02:00
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
|
<?php
|
||
|
/*
|
||
|
* This file is part of the Magallanes package.
|
||
|
*
|
||
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
|
||
|
namespace Mage\Task\BuiltIn\Git;
|
||
|
|
||
|
use Symfony\Component\Process\Process;
|
||
|
use Mage\Task\AbstractTask;
|
||
|
|
||
|
/**
|
||
|
* Git Task - Pull
|
||
|
*
|
||
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
||
|
*/
|
||
|
class UpdateTask extends AbstractTask
|
||
|
{
|
||
|
public function getName()
|
||
|
{
|
||
|
return 'git/update';
|
||
|
}
|
||
|
|
||
|
public function getDescription()
|
||
|
{
|
||
|
return '[Git] Update';
|
||
|
}
|
||
|
|
||
|
public function execute()
|
||
|
{
|
||
|
$options = $this->getOptions();
|
||
|
$command = $options['path'] . ' pull';
|
||
|
|
||
|
/** @var Process $process */
|
||
|
$process = $this->runtime->runLocalCommand($command);
|
||
|
|
||
|
return $process->isSuccessful();
|
||
|
}
|
||
|
|
||
|
protected function getOptions()
|
||
|
{
|
||
|
$config = $this->runtime->getEnvironmentConfig();
|
||
|
$branch = 'master';
|
||
|
if (array_key_exists('branch', $config)) {
|
||
|
$branch = $config['branch'];
|
||
|
}
|
||
|
|
||
|
$options = array_merge(
|
||
|
['path' => 'git', 'branch' => $branch],
|
||
|
$this->options
|
||
|
);
|
||
|
|
||
|
return $options;
|
||
|
}
|
||
|
}
|