Skip to content

Commit

Permalink
Runners: added OldGitRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Dec 10, 2022
1 parent 24f4e51 commit bb195e3
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Runners/OldGitRunner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace CzProject\GitPhp\Runners;

use CzProject\GitPhp\IRunner;


class OldGitRunner implements IRunner
{
/** @var IRunner */
private $runner;


public function __construct(IRunner $runner = NULL)
{
$this->runner = $runner !== NULL ? $runner : new CliRunner;
}


public function run($cwd, array $args, array $env = NULL)
{
if (($key = array_search('--end-of-options', $args)) !== FALSE) {
unset($args[$key]);
}

return $this->runner->run($cwd, $args, $env);
}


public function getCwd()
{
return $this->runner->getCwd();
}
}
25 changes: 25 additions & 0 deletions tests/GitPhp/OldGitRunner.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use CzProject\GitPhp\Git;
use CzProject\GitPhp\Runners\OldGitRunner;
use CzProject\GitPhp\Tests\AssertRunner;

require __DIR__ . '/bootstrap.php';

$assertRunner = new AssertRunner(__DIR__);
$runner = new OldGitRunner($assertRunner);
$git = new Git($runner);

$assertRunner->assert(['branch', 'master']);
$assertRunner->assert(['branch', 'develop']);
$assertRunner->assert(['checkout', 'develop']);
$assertRunner->assert(['merge', 'feature-1']);
$assertRunner->assert(['branch', '-d', 'feature-1']);
$assertRunner->assert(['checkout', 'master']);

$repo = $git->open(__DIR__);
$repo->createBranch('master');
$repo->createBranch('develop', TRUE);
$repo->merge('feature-1');
$repo->removeBranch('feature-1');
$repo->checkout('master');

0 comments on commit bb195e3

Please sign in to comment.