Skip to content

Commit 0d437f2

Browse files
committed
GitRepository: uses '--no-color' option for 'git branch' commands
1 parent 96aca96 commit 0d437f2

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/GitRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function removeBranch($name)
166166
public function getCurrentBranchName()
167167
{
168168
try {
169-
$branch = $this->extractFromCommand(['branch', '-a'], function($value) {
169+
$branch = $this->extractFromCommand(['branch', '-a', '--no-color'], function($value) {
170170
if (isset($value[0]) && $value[0] === '*') {
171171
return trim(substr($value, 1));
172172
}
@@ -193,7 +193,7 @@ public function getCurrentBranchName()
193193
*/
194194
public function getBranches()
195195
{
196-
return $this->extractFromCommand(['branch', '-a'], function($value) {
196+
return $this->extractFromCommand(['branch', '-a', '--no-color'], function($value) {
197197
return trim(substr($value, 1));
198198
});
199199
}
@@ -206,7 +206,7 @@ public function getBranches()
206206
*/
207207
public function getRemoteBranches()
208208
{
209-
return $this->extractFromCommand(['branch', '-r'], function($value) {
209+
return $this->extractFromCommand(['branch', '-r', '--no-color'], function($value) {
210210
return trim(substr($value, 1));
211211
});
212212
}
@@ -219,7 +219,7 @@ public function getRemoteBranches()
219219
*/
220220
public function getLocalBranches()
221221
{
222-
return $this->extractFromCommand(['branch'], function($value) {
222+
return $this->extractFromCommand(['branch', '--no-color'], function($value) {
223223
return trim(substr($value, 1));
224224
});
225225
}

tests/GitPhp/GitRepository.getBranches.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $runner = new MemoryRunner(__DIR__);
1111
$git = new Git($runner);
1212
$repo = $git->open(__DIR__);
1313

14-
$runner->setResult(['branch', '-a'], [], [
14+
$runner->setResult(['branch', '-a', '--no-color'], [], [
1515
' master',
1616
'* develop',
1717
' remotes/origin/master',
@@ -23,5 +23,5 @@ Assert::same([
2323
], $repo->getBranches());
2424

2525

26-
$runner->setResult(['branch', '-a'], [], []);
26+
$runner->setResult(['branch', '-a', '--no-color'], [], []);
2727
Assert::null($repo->getBranches());

tests/GitPhp/GitRepository.getCurrentBranchName.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ $runner = new MemoryRunner(__DIR__);
1111
$git = new Git($runner);
1212
$repo = $git->open(__DIR__);
1313

14-
$runner->setResult(['branch', '-a'], [], [
14+
$runner->setResult(['branch', '-a', '--no-color'], [], [
1515
' master',
1616
'* develop',
1717
' remotes/origin/master',
1818
]);
1919
Assert::same('develop', $repo->getCurrentBranchName());
2020

2121

22-
$runner->setResult(['branch', '-a'], [], []);
22+
$runner->setResult(['branch', '-a', '--no-color'], [], []);
2323
Assert::exception(function () use ($repo) {
2424
$repo->getCurrentBranchName();
2525
}, GitException::class, 'Getting of current branch name failed.');
2626

2727

28-
$runner->setResult(['branch', '-a'], [], [], [], 1);
28+
$runner->setResult(['branch', '-a', '--no-color'], [], [], [], 1);
2929
Assert::exception(function () use ($repo) {
3030
$repo->getCurrentBranchName();
3131
}, GitException::class, 'Getting of current branch name failed.');

tests/GitPhp/GitRepository.getLocalBranches.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $runner = new MemoryRunner(__DIR__);
1111
$git = new Git($runner);
1212
$repo = $git->open(__DIR__);
1313

14-
$runner->setResult(['branch'], [], [
14+
$runner->setResult(['branch', '--no-color'], [], [
1515
' master',
1616
'* develop',
1717
]);
@@ -21,5 +21,5 @@ Assert::same([
2121
], $repo->getLocalBranches());
2222

2323

24-
$runner->setResult(['branch'], [], []);
24+
$runner->setResult(['branch', '--no-color'], [], []);
2525
Assert::null($repo->getLocalBranches());

tests/GitPhp/GitRepository.getRemoteBranches.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $runner = new MemoryRunner(__DIR__);
1111
$git = new Git($runner);
1212
$repo = $git->open(__DIR__);
1313

14-
$runner->setResult(['branch', '-r'], [], [
14+
$runner->setResult(['branch', '-r', '--no-color'], [], [
1515
' origin/master',
1616
'* origin/version-2'
1717
]);
@@ -21,5 +21,5 @@ Assert::same([
2121
], $repo->getRemoteBranches());
2222

2323

24-
$runner->setResult(['branch', '-r'], [], []);
24+
$runner->setResult(['branch', '-r', '--no-color'], [], []);
2525
Assert::null($repo->getRemoteBranches());

0 commit comments

Comments
 (0)