(Grav GitSync) Automatic Commit from smokephil
This commit is contained in:
commit
4267db646d
2765 changed files with 462171 additions and 0 deletions
45
plugins/git-sync/cli/InitCommand.php
Normal file
45
plugins/git-sync/cli/InitCommand.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php namespace Grav\Plugin\Console;
|
||||
|
||||
use Grav\Console\ConsoleCommand;
|
||||
use Grav\Plugin\GitSync\GitSync;
|
||||
|
||||
/**
|
||||
* Class InitCommand
|
||||
*
|
||||
* @package Grav\Plugin\Console
|
||||
*/
|
||||
class InitCommand extends ConsoleCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('init')
|
||||
->setDescription('Initializes your git repository')
|
||||
->setHelp('The <info>init</info> command runs the same git commands as the onAdminAfterSave function. Use this to manually initialize git-sync (useful for automated deployments).')
|
||||
;
|
||||
}
|
||||
|
||||
protected function serve()
|
||||
{
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$plugin = new GitSync();
|
||||
$repository = $plugin->getConfig('repository', false);
|
||||
|
||||
$this->output->writeln('');
|
||||
|
||||
if (!$repository) {
|
||||
$this->output->writeln('<red>ERROR:</red> No repository has been configured!');
|
||||
}
|
||||
|
||||
$this->output->writeln('Initializing <cyan>' . $repository . '</cyan>');
|
||||
|
||||
$this->output->write('Starting initialization...');
|
||||
|
||||
$plugin->initializeRepository();
|
||||
$plugin->setUser();
|
||||
$plugin->addRemote();
|
||||
|
||||
$this->output->writeln('completed.');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue