Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly parsing commit body, fixes #137

  • Loading branch information...
commit 919c953f832cdc9d6dd00ca35d094a9260121765 1 parent b73af1a
@klaussilveira authored
Showing with 10 additions and 3 deletions.
  1. +7 −3 src/GitList/Git/Repository.php
  2. +3 −0  views/commit.twig
View
10 src/GitList/Git/Repository.php
@@ -42,12 +42,16 @@ public function getHead($default = null)
*/
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]);
View
3  views/commit.twig
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.