mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 19:20:56 +01:00
Properly parsing commit body, fixes #137
This commit is contained in:
@@ -42,12 +42,16 @@ class Repository extends BaseRepository
|
||||
*/
|
||||
public function getCommit($commitHash)
|
||||
{
|
||||
$logs = $this->getClient()->run($this, "show --pretty=format:\"<item><hash>%H</hash><short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents><author>%an</author><author_email>%ae</author_email><date>%at</date><commiter>%cn</commiter><commiter_email>%ce</commiter_email><commiter_date>%ct</commiter_date><message><![CDATA[%s]]></message></item>\" $commitHash");
|
||||
$logs = explode("\n", $logs);
|
||||
$logs = $this->getClient()->run($this, "show --pretty=format:\"<item><hash>%H</hash><short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents><author>%an</author><author_email>%ae</author_email><date>%at</date><commiter>%cn</commiter><commiter_email>%ce</commiter_email><commiter_date>%ct</commiter_date><message><![CDATA[%s]]></message><body><![CDATA[%b]]></body></item>\" $commitHash");
|
||||
$xmlEnd = strpos($logs, '</item>') + 7;
|
||||
$commitInfo = substr($logs, 0, $xmlEnd);
|
||||
$commitData = substr($logs, $xmlEnd);
|
||||
$logs = explode("\n", $commitData);
|
||||
array_shift($logs);
|
||||
|
||||
// Read commit metadata
|
||||
$format = new PrettyFormat;
|
||||
$data = $format->parse($logs[0]);
|
||||
$data = $format->parse($commitInfo);
|
||||
$commit = new Commit;
|
||||
$commit->importData($data[0]);
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<h4>{{ commit.message }}</h4>
|
||||
</div>
|
||||
<div class="commit-body">
|
||||
{% if commit.body is not empty %}
|
||||
<p>{{ commit.body | nl2br }}</p>
|
||||
{% endif %}
|
||||
<img src="https://gravatar.com/avatar/{{ commit.author.email | lower | md5 }}?s=32" class="pull-left space-right" />
|
||||
<span><a href="mailto:{{ commit.author.email }}">{{ commit.author.name }}</a> authored on {{ commit.date | date('d/m/Y \\a\\t H:i:s') }}<br />Showing {{ commit.changedFiles }} changed files</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user