Skip to content

Instantly share code, notes, and snippets.

@makasim
Created November 14, 2014 05:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makasim/cae218475fafe9e16024 to your computer and use it in GitHub Desktop.
Save makasim/cae218475fafe9e16024 to your computer and use it in GitHub Desktop.
<?php
namespace Payum\SiteBundle\Command;
use Payum\SiteBundle\Model\Library;
use Payum\SiteBundle\Service\LibraryRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
class RunSubtreeSplitCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('payum:lib:run-subtree-split')
->setDescription('It runs several git commands to actually split the payum/payum into several subtrees.')
;
}
/**
* {@inheritdoc}
* @throws \RuntimeException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getContainer()->get('library.prepare_temp_dir')->prepare();
$command = 'git clone git@github.com:Payum/Payum.git Payum';
$output->writeln("\t$command");
$process = new Process($command);
$process->setTimeout(180);
$process->setWorkingDirectory($this->getContainer()->getParameter('app.temp_docs_dir'));
$process->run();
if (false == $process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
$commandOutput = "\t".str_replace("\n", "\n\t", (string) $process->getOutput());
if (trim($commandOutput)) {
$output->writeln($commandOutput);
}
$stableVersion = $this->getContainer()->getParameter('payum.stable_version');
$devVersion = 'master';
$commands = array(
"git remote add core git@github.com:Payum/Core.git",
"git remote add paypal-pro-checkout git@github.com:Payum/PaypalProCheckoutNvp.git",
"git remote add authorize-net-aim git@github.com:Payum/AuthorizeNetAim.git",
"git remote add be2bill git@github.com:Payum/Be2Bill.git",
"git remote add paypal-express-checkout git@github.com:Payum/PaypalExpressCheckoutNvp.git",
"git remote add paypal-ipn git@github.com:Payum/PaypalIpn.git",
"git remote add paypal-rest git@github.com:Payum/PaypalRest.git",
"git remote add offline git@github.com:Payum/Offline.git",
"git remote add payex git@github.com:Payum/Payex.git",
"git remote add klarna-checkout git@github.com:Payum/KlarnaCheckout.git",
"git remote add klarna-invoice git@github.com:Payum/KlarnaInvoice.git",
"git remote add stripe git@github.com:Payum/Stripe.git",
"git checkout $devVersion",
"git subtree push --prefix='src/Payum/Core/' core $devVersion",
"git subtree push --prefix='src/Payum/Paypal/ProCheckout/Nvp' paypal-pro-checkout $devVersion",
"git subtree push --prefix='src/Payum/AuthorizeNet/Aim/' authorize-net-aim $devVersion",
"git subtree push --prefix='src/Payum/Be2Bill' be2bill $devVersion",
"git subtree push --prefix='src/Payum/Paypal/ExpressCheckout/Nvp' paypal-express-checkout $devVersion",
"git subtree push --prefix='src/Payum/Paypal/Ipn' paypal-ipn $devVersion",
"git subtree push --prefix='src/Payum/Paypal/Rest' paypal-rest $devVersion",
"git subtree push --prefix='src/Payum/Offline' offline $devVersion",
"git subtree push --prefix='src/Payum/Payex' payex $devVersion",
"git subtree push --prefix='src/Payum/Klarna/Checkout' klarna-checkout $devVersion",
"git subtree push --prefix='src/Payum/Klarna/Invoice' klarna-invoice $devVersion",
"git subtree push --prefix='src/Payum/Stripe' stripe $devVersion",
"git checkout $stableVersion",
"git subtree push --prefix='src/Payum/Core/' core $stableVersion",
"git subtree push --prefix='src/Payum/Paypal/ProCheckout/Nvp' paypal-pro-checkout $stableVersion",
"git subtree push --prefix='src/Payum/AuthorizeNet/Aim/' authorize-net-aim $stableVersion",
"git subtree push --prefix='src/Payum/Be2Bill' be2bill $stableVersion",
"git subtree push --prefix='src/Payum/Paypal/ExpressCheckout/Nvp' paypal-express-checkout $stableVersion",
"git subtree push --prefix='src/Payum/Paypal/Ipn' paypal-ipn $stableVersion",
"git subtree push --prefix='src/Payum/Paypal/Rest' paypal-rest $stableVersion",
"git subtree push --prefix='src/Payum/Offline' offline $stableVersion",
"git subtree push --prefix='src/Payum/Payex' payex $stableVersion",
"git subtree push --prefix='src/Payum/Klarna/Checkout' klarna-checkout $stableVersion",
"git subtree push --prefix='src/Payum/Klarna/Invoice' klarna-invoice $stableVersion",
"git subtree push --prefix='src/Payum/Stripe' stripe $stableVersion",
);
foreach ($commands as $command) {
$output->writeln("\t$command");
$process = new Process($command);
$process->setTimeout(180);
$process->setWorkingDirectory($this->getContainer()->getParameter('app.temp_docs_dir').'/Payum');
$process->run();
if (false == $process->isSuccessful()) {
throw new \RuntimeException($process->getErrorOutput());
}
$commandOutput = "\t".str_replace("\n", "\n\t", (string) $process->getOutput());
if (trim($commandOutput)) {
$output->writeln($commandOutput);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment