mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Issue #57: Interleave commits in blame
This commit is contained in:
@@ -477,24 +477,27 @@ class Repository
|
|||||||
*/
|
*/
|
||||||
public function getBlame($file)
|
public function getBlame($file)
|
||||||
{
|
{
|
||||||
|
$blame = array();
|
||||||
$logs = $this->getClient()->run($this, "blame -s $file");
|
$logs = $this->getClient()->run($this, "blame -s $file");
|
||||||
$logs = explode("\n", $logs);
|
$logs = explode("\n", $logs);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$previous_commit = '';
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $log) {
|
||||||
if ($log == '') {
|
if ($log == '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$split = preg_split("/[a-zA-Z0-9^]{8}[\s]+[0-9]+\)/", $log);
|
preg_match_all("/([a-zA-Z0-9^]{8})[\s]+(.+)[\s]+([0-9]+)\)(.+)/", $log, $match);
|
||||||
preg_match_all("/([a-zA-Z0-9^]{8})[\s]+([0-9]+)\)/", $log, $match);
|
|
||||||
|
|
||||||
$commit = $match[1][0];
|
$current_commit = $match[1][0];
|
||||||
|
if ($current_commit != $previous_commit) {
|
||||||
if (!isset($blame[$commit]['line'])) {
|
++$i;
|
||||||
$blame[$commit]['line'] = '';
|
$blame[$i] = array('line' => '', 'commit' => $current_commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$blame[$commit]['line'] .= PHP_EOL . $split[1];
|
$blame[$i]['line'] .= PHP_EOL . $match[4][0];
|
||||||
|
$previous_commit = $current_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $blame;
|
return $blame;
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
<div class="meta">{{ file }}</div>
|
<div class="meta">{{ file }}</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="blame-view">
|
<table class="blame-view">
|
||||||
{% for commit, blame in blames %}
|
{% for blame in blames %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="commit"><a href="{{ baseurl }}/{{ repo }}/commit/{{ commit }}/">{{ commit }}</a></td>
|
<td class="commit"><a href="{{ baseurl }}/{{ repo }}/commit/{{ blame.commit }}/">{{ blame.commit }}</a></td>
|
||||||
<td><pre>{{ blame.line }}</pre></td>
|
<td><pre>{{ blame.line }}</pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user