Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Gitonomy/Git/Commit.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ public function getIncludingBranches($local = true, $remote = true)
}

$branchesName = explode("\n", trim(str_replace('*', '', $result)));
$branchesName = array_filter($branchesName, function ($v) { return false === StringHelper::strpos($v, '->');});
$branchesName = array_filter($branchesName, function ($v) {
return false === StringHelper::strpos($v, '->');
});
$branchesName = array_map('trim', $branchesName);

$references = $this->repository->getReferences();
Expand Down
6 changes: 4 additions & 2 deletions src/Gitonomy/Git/Diff/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function toArray()
'files' => array_map(
function (File $file) {
return $file->toArray();
}, $this->files
},
$this->files
),
);
}
Expand All @@ -119,7 +120,8 @@ public static function fromArray(array $array)
array_map(
function ($array) {
return File::fromArray($array);
}, $array['files']
},
$array['files']
),
$array['rawDiff']
);
Expand Down
3 changes: 2 additions & 1 deletion src/Gitonomy/Git/Exception/ProcessException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ProcessException extends RuntimeException implements GitExceptionInterface

public function __construct(Process $process)
{
parent::__construct("Error while running git command:\n".
parent::__construct(
"Error while running git command:\n".
$process->getCommandLine()."\n".
"\n".
$process->getErrorOutput()."\n".
Expand Down
3 changes: 1 addition & 2 deletions src/Gitonomy/Git/Parser/LogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ protected function doParse()
$message .= $this->consumeTo("\n")."\n";
$this->consumeNewLine();
}
}
else {
} else {
$this->cursor--;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Gitonomy/Git/Parser/ParserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ protected function consumeNewLine()
/**
* @return string
*/
protected function consumeGPGSignature() {
protected function consumeGPGSignature()
{
$expected = "\ngpgsig ";
$length = strlen($expected);
$actual = substr($this->content, $this->cursor, $length);
if($actual != $expected) {
if ($actual != $expected) {
return '';
}
$this->cursor += $length;
Expand Down
2 changes: 1 addition & 1 deletion src/Gitonomy/Git/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private function initDir($gitDir, $workingDir = null)

if (false === $realGitDir) {
throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $gitDir));
} else if (!is_dir($realGitDir)) {
} elseif (!is_dir($realGitDir)) {
throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $realGitDir));
} elseif (null === $workingDir && is_dir($realGitDir.'/.git')) {
$workingDir = $realGitDir;
Expand Down
8 changes: 6 additions & 2 deletions src/Gitonomy/Git/WorkingCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public function getStatus()
public function getUntrackedFiles()
{
$lines = explode("\0", $this->run('status', array('--porcelain', '--untracked-files=all', '-z')));
$lines = array_filter($lines, function ($l) { return substr($l, 0, 3) === '?? '; });
$lines = array_map(function ($l) { return substr($l, 3); }, $lines);
$lines = array_filter($lines, function ($l) {
return substr($l, 0, 3) === '?? ';
});
$lines = array_map(function ($l) {
return substr($l, 3);
}, $lines);

return $lines;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gitonomy/Git/Tests/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testBare()
$objectDir = $this->tmpDir.'/objects';

$this->assertTrue($repository->isBare(), 'Repository is bare');
$this->assertTrue(is_dir($objectDir), 'objects/ folder is present');
$this->assertTrue(is_dir($objectDir), 'objects/ folder is present');
$this->assertTrue($repository instanceof Repository, 'Admin::init returns a repository');
$this->assertEquals($this->tmpDir, $repository->getGitDir(), 'The folder passed as argument is git dir');
$this->assertNull($repository->getWorkingDir(), 'No working dir in bare repository');
Expand Down
12 changes: 6 additions & 6 deletions tests/Gitonomy/Git/Tests/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ protected function verifyCreateCommitDiff(Diff $diff)

$this->assertTrue($files[0]->isCreation(), 'script_A.php created');

$this->assertEquals(null, $files[0]->getOldName(), 'First file name is a new file');
$this->assertEquals(null, $files[0]->getOldName(), 'First file name is a new file');
$this->assertEquals('script_A.php', $files[0]->getNewName(), 'First file name is script_A.php');
$this->assertEquals(null, $files[0]->getOldMode(), 'First file mode is a new file');
$this->assertEquals('100644', $files[0]->getNewMode(), 'First file mode is correct');
$this->assertEquals(null, $files[0]->getOldMode(), 'First file mode is a new file');
$this->assertEquals('100644', $files[0]->getNewMode(), 'First file mode is correct');

$this->assertEquals(1, $files[0]->getAdditions(), '1 line added');
$this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted');
$this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted');
}

/**
Expand All @@ -70,8 +70,8 @@ public function testGetFiles_Modification($repository)

$this->assertEquals('image.jpg', $files[0]->getOldName(), 'Second file name is image.jpg');
$this->assertEquals('image.jpg', $files[0]->getNewName(), 'Second file name is image.jpg');
$this->assertEquals('100644', $files[0]->getOldMode(), 'Second file mode is a new file');
$this->assertEquals('100644', $files[0]->getNewMode(), 'Second file mode is correct');
$this->assertEquals('100644', $files[0]->getOldMode(), 'Second file mode is a new file');
$this->assertEquals('100644', $files[0]->getNewMode(), 'Second file mode is correct');

$this->assertTrue($files[0]->isBinary(), 'binary file');
$this->assertEquals(0, $files[0]->getAdditions(), '0 lines added');
Expand Down
8 changes: 4 additions & 4 deletions tests/Gitonomy/Git/Tests/PushReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function provideIsers()
public function testIsers($reference, $before, $after, $mask)
{
$reference = new PushReference(self::createFoobarRepository(), $reference, $before, $after);
$this->assertEquals($mask & self::CREATE, $reference->isCreate(), 'Create value is correct.');
$this->assertEquals($mask & self::DELETE, $reference->isDelete(), 'Delete value is correct.');
$this->assertEquals($mask & self::FORCE, $reference->isForce(), 'Force value is correct.');
$this->assertEquals($mask & self::FAST_FORWARD, $reference->isFastForward(), 'FastForward value is correct.');
$this->assertEquals($mask & self::CREATE, $reference->isCreate(), 'Create value is correct.');
$this->assertEquals($mask & self::DELETE, $reference->isDelete(), 'Delete value is correct.');
$this->assertEquals($mask & self::FORCE, $reference->isForce(), 'Force value is correct.');
$this->assertEquals($mask & self::FAST_FORWARD, $reference->isFastForward(), 'FastForward value is correct.');
}

/**
Expand Down