From 637c675c3f7e811e2e56c8ab94690640d453ab8e Mon Sep 17 00:00:00 2001 From: stovak <119924+stovak@users.noreply.github.com> Date: Mon, 14 Jun 2021 21:49:30 -0700 Subject: [PATCH] commit-and-push command buildout --- src/Commands/D9ify/CommitAndPushCommand.php | 9 ++- src/Commands/D9ify/ProcessCommand.php | 1 - src/Commands/Local/CommitAndPushCommand.php | 62 +++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/Commands/Local/CommitAndPushCommand.php diff --git a/src/Commands/D9ify/CommitAndPushCommand.php b/src/Commands/D9ify/CommitAndPushCommand.php index 97d0bdb1d..ef8974d3a 100644 --- a/src/Commands/D9ify/CommitAndPushCommand.php +++ b/src/Commands/D9ify/CommitAndPushCommand.php @@ -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; /** @@ -21,6 +22,8 @@ class CommitAndPushCommand extends TerminusCommand use SiteAwareTrait; use ConfigAwareTrait; + use IO; + use SiteAwareTrait; /** * @var string @@ -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(); } diff --git a/src/Commands/D9ify/ProcessCommand.php b/src/Commands/D9ify/ProcessCommand.php index bc0fde836..db583a99c 100644 --- a/src/Commands/D9ify/ProcessCommand.php +++ b/src/Commands/D9ify/ProcessCommand.php @@ -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. diff --git a/src/Commands/Local/CommitAndPushCommand.php b/src/Commands/Local/CommitAndPushCommand.php new file mode 100644 index 000000000..9c7aacea3 --- /dev/null +++ b/src/Commands/Local/CommitAndPushCommand.php @@ -0,0 +1,62 @@ + 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'); + } +}