/** * Parse the git log * * @return array */ public function parse() { $result = $this->command->run(); $log = $result->getStdOut(); $buffer = array(); $commits = explode($this->format->getCommitDelimiter(), $log); foreach ($commits as $commit) { $fields = explode($this->format->getFieldDelimiter(), $commit); $entry = array(); foreach ($fields as $field) { if (!preg_match('/^\\[(\\S*)\\](.*)/', $field, $matches)) { continue; } $entry[trim($matches[1])] = trim($matches[2]); } if (!empty($entry)) { $buffer[] = $entry; } } return $buffer; }
/** * @covers \Tivie\Command\Command::chdir * @covers \Tivie\Command\Command::setCurrentWorkingDirectory * @covers \Tivie\Command\Command::exec * @covers \Tivie\Command\Command::proc_open */ public function testChdir() { $s = DIRECTORY_SEPARATOR; $dir = realpath(__DIR__ . $s . ".." . $s . "dir" . $s . "test" . $s); if (!$dir) { // something went wrong setting the relative path so we inform and quick gracefully fwrite(STDERR, "CommandTest::testChdir() - Failed to discover the test directory in testChdir so the " . "test was skipped"); return; } $cmd = new Command(); if ($this->os->isWindowsLike()) { $cmd->setCommand('cd'); } else { $cmd->setCommand('pwd'); } // Test with no working directory $result = $this->getResultMock(); $result->expects($this->once())->method('setStdOut')->with($this->equalTo(realpath(getcwd()))); $cmd->run($result); // Test with working directory $cmd->setCurrentWorkingDirectory($dir); //Test with exec $cmd->setFlags(FORCE_USE_EXEC); $result = $this->getResultMock(); $result->expects($this->once())->method('setStdOut')->with($this->equalTo($dir)); $cmd->run($result); //Test with proc_open $cmd->setFlags(FORCE_USE_PROC_OPEN); $result = $this->getResultMock(); $result->expects($this->once())->method('setStdOut')->with($this->equalTo($dir)); $cmd->run($result); }