Skip to content

Commit

Permalink
commit-and-push command buildout
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Jun 15, 2021
1 parent fe523f0 commit 637c675
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Commands/D9ify/CommitAndPushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Pantheon\Terminus\Config\ConfigAwareTrait;
use Pantheon\Terminus\Helpers\Site\Directory;
use Pantheon\Terminus\Site\SiteAwareTrait;
use Robo\Common\IO;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand All @@ -21,6 +22,8 @@ class CommitAndPushCommand extends TerminusCommand

use SiteAwareTrait;
use ConfigAwareTrait;
use IO;
use SiteAwareTrait;

/**
* @var string
Expand Down Expand Up @@ -74,9 +77,9 @@ public function commitAndPush(string $site)
$this->output(),
)
);
$this->restoreDatabaseToDestinationSite($this->output());
$this->unpackSiteFilesAndRsyncToDestination($this->output());
$this->checkinVersionManagedFilesAndPush($this->output());
$this->restoreDatabaseToDestinationSite();
$this->unpackSiteFilesAndRsyncToDestination();
$this->checkinVersionManagedFilesAndPush();
}


Expand Down
1 change: 0 additions & 1 deletion src/Commands/D9ify/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class ProcessCommand extends TerminusCommand implements SiteAwareInterface, Conf
*/
public function process($sourceSite, $destinationSite = null, $options = [])
{
$GLOBALS['_kint_settings']['depthLimit'] = 3;
$this->output()->writeln(static::$HELP_TEXT);
try {
// Handle Source Site.
Expand Down
62 changes: 62 additions & 0 deletions src/Commands/Local/CommitAndPushCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Pantheon\Terminus\Commands\Local;

use Consolidation\OutputFormatters\StructuredData\AbstractStructuredList;
use Consolidation\OutputFormatters\StructuredData\PropertyList;
use Pantheon\Terminus\Commands\TerminusCommand;
use Pantheon\Terminus\Commands\WorkflowProcessingTrait;
use Pantheon\Terminus\Config\ConfigAwareTrait;
use Pantheon\Terminus\Friends\LocalCopiesTrait;
use Pantheon\Terminus\Helpers\Traits\CommandExecutorTrait;
use Pantheon\Terminus\Models\Site;
use Pantheon\Terminus\Site\SiteAwareInterface;
use Pantheon\Terminus\Site\SiteAwareTrait;
use Pantheon\Terminus\Exceptions\TerminusException;
use Robo\Contract\ConfigAwareInterface;

/**
* @name LocalCommands
* Class CloneCommand
* @package Pantheon\Terminus\Commands\Local
*/
class CommitAndPushCommand extends TerminusCommand implements SiteAwareInterface, ConfigAwareInterface
{
use SiteAwareTrait;
use ConfigAwareTrait;
use CommandExecutorTrait;

/**
* CLone's a local copy of the site's code into "$HOME/pantheon-local-copies"
*
* @authorize
*
* @command local:clone
* @aliases lc
*
* @param string $site Site
*
* @usage <site> Clone's a local copy into "$HOME/pantheon-local-copies"
*@return string
* @throws \Pantheon\Terminus\Exceptions\TerminusException
*
*/
public function commitAndPushCommand($site) : string
{
$siteData = $site;
if (!$siteData instanceof Site) {
$siteData = $this->getSite($site);
if (!$siteData instanceof Site) {
throw new TerminusException(
"Cannot find site with the ID: {site}",
["site" => $site]
);
}
}
$git = new \CzProject\GitPhp\Git();
$repo = $git->open($siteData->getLocalCopyFolder());
$repo->addAllChanges();
$repo->commit('changes committed from terminus');
$repo->push('origin');
}
}

0 comments on commit 637c675

Please sign in to comment.