mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 11:10:57 +01:00
diff output parsing skips empty lines.
This commit is contained in:
@@ -52,11 +52,11 @@ class Repository extends BaseRepository
|
|||||||
. "<body><![CDATA[%b]]></body>"
|
. "<body><![CDATA[%b]]></body>"
|
||||||
. "</item>\" $commitHash"
|
. "</item>\" $commitHash"
|
||||||
);
|
);
|
||||||
|
|
||||||
$xmlEnd = strpos($logs, '</item>') + 7;
|
$xmlEnd = strpos($logs, '</item>') + 7;
|
||||||
$commitInfo = substr($logs, 0, $xmlEnd);
|
$commitInfo = substr($logs, 0, $xmlEnd);
|
||||||
$commitData = substr($logs, $xmlEnd);
|
$commitData = substr($logs, $xmlEnd);
|
||||||
$logs = explode("\n", $commitData);
|
$logs = explode("\n", $commitData);
|
||||||
array_shift($logs);
|
|
||||||
|
|
||||||
// Read commit metadata
|
// Read commit metadata
|
||||||
$format = new PrettyFormat;
|
$format = new PrettyFormat;
|
||||||
@@ -67,8 +67,6 @@ class Repository extends BaseRepository
|
|||||||
if ($commit->getParentsHash()) {
|
if ($commit->getParentsHash()) {
|
||||||
$command = 'diff ' . $commitHash . '~1..' . $commitHash;
|
$command = 'diff ' . $commitHash . '~1..' . $commitHash;
|
||||||
$logs = explode("\n", $this->getClient()->run($this, $command));
|
$logs = explode("\n", $this->getClient()->run($this, $command));
|
||||||
} else {
|
|
||||||
$logs = array_slice($logs, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit->setDiffs($this->readDiffLogs($logs));
|
$commit->setDiffs($this->readDiffLogs($logs));
|
||||||
@@ -126,6 +124,11 @@ class Repository extends BaseRepository
|
|||||||
$lineNumOld = 0;
|
$lineNumOld = 0;
|
||||||
$lineNumNew = 0;
|
$lineNumNew = 0;
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $log) {
|
||||||
|
# Skip empty lines
|
||||||
|
if ($log == "") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ('diff' === substr($log, 0, 4)) {
|
if ('diff' === substr($log, 0, 4)) {
|
||||||
if (isset($diff)) {
|
if (isset($diff)) {
|
||||||
$diffs[] = $diff;
|
$diffs[] = $diff;
|
||||||
|
|||||||
Reference in New Issue
Block a user