Skip to content

Commit bb195e3

Browse files
committed
Runners: added OldGitRunner
#82 #86
1 parent 24f4e51 commit bb195e3

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/Runners/OldGitRunner.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace CzProject\GitPhp\Runners;
4+
5+
use CzProject\GitPhp\IRunner;
6+
7+
8+
class OldGitRunner implements IRunner
9+
{
10+
/** @var IRunner */
11+
private $runner;
12+
13+
14+
public function __construct(IRunner $runner = NULL)
15+
{
16+
$this->runner = $runner !== NULL ? $runner : new CliRunner;
17+
}
18+
19+
20+
public function run($cwd, array $args, array $env = NULL)
21+
{
22+
if (($key = array_search('--end-of-options', $args)) !== FALSE) {
23+
unset($args[$key]);
24+
}
25+
26+
return $this->runner->run($cwd, $args, $env);
27+
}
28+
29+
30+
public function getCwd()
31+
{
32+
return $this->runner->getCwd();
33+
}
34+
}

tests/GitPhp/OldGitRunner.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use CzProject\GitPhp\Git;
4+
use CzProject\GitPhp\Runners\OldGitRunner;
5+
use CzProject\GitPhp\Tests\AssertRunner;
6+
7+
require __DIR__ . '/bootstrap.php';
8+
9+
$assertRunner = new AssertRunner(__DIR__);
10+
$runner = new OldGitRunner($assertRunner);
11+
$git = new Git($runner);
12+
13+
$assertRunner->assert(['branch', 'master']);
14+
$assertRunner->assert(['branch', 'develop']);
15+
$assertRunner->assert(['checkout', 'develop']);
16+
$assertRunner->assert(['merge', 'feature-1']);
17+
$assertRunner->assert(['branch', '-d', 'feature-1']);
18+
$assertRunner->assert(['checkout', 'master']);
19+
20+
$repo = $git->open(__DIR__);
21+
$repo->createBranch('master');
22+
$repo->createBranch('develop', TRUE);
23+
$repo->merge('feature-1');
24+
$repo->removeBranch('feature-1');
25+
$repo->checkout('master');

0 commit comments

Comments
 (0)