data/templates/revision-head.htm - ADD: display commit message
authorJustin J. Novack <jnovack@gmail.com>
Sun, 16 Sep 2012 19:17:28 +0000 (15:17 -0400)
committerJustin J. Novack <jnovack@gmail.com>
Sun, 16 Sep 2012 19:17:28 +0000 (15:17 -0400)
data/templates/revision-head.htm
src/phorkie/Repository.php

index 132a68feb93bdcdd5993709b8e6e05354d86c4ff..a5f7e88cf9b95ebe668bdf7a7ad03856fe057bfd 100644 (file)
@@ -10,6 +10,7 @@
    revision <strong>{{repo.hash}}</strong>
   </p>
   <p>
+   message <strong>{{repo.message}}</strong>
   </p>
  </div>
  <div class="span2">
index 448982baa2da6c54252731382fd746cc61d832e9..6ed380741ee4a2c0c2479887e8adec48ceac817d 100644 (file)
@@ -32,6 +32,12 @@ class Repository
      */
     public $hash;
 
+    /**
+     * Commit message of the last (or current) revision
+     *
+     * @var string
+     */
+    public $message;
 
 
     /**
@@ -56,6 +62,7 @@ class Repository
         $this->id = (int)$_GET['id'];
         $this->loadDirs();
         $this->loadHash();
+        $this->loadMessage();
     }
 
     protected function loadDirs()
@@ -97,6 +104,23 @@ class Repository
         $this->hash = $output;
     }
 
+    public function loadMessage()
+    {
+        $rev = (isset($this->hash)) ? $this->hash : 'HEAD';
+        $output = $this->getVc()->getCommand('log')
+            ->setOption('oneline')
+            ->addArgument('-1')
+            ->addArgument($rev)
+            ->execute();
+        $output = trim($output);
+        if (strpos($output, ' ') > 0) {
+            $output = substr($output, strpos($output, ' '), strlen($output));
+            $this->message = trim($output);
+        } else {
+            $this->message = "This commit message intentionally left blank.";
+               }
+    }
+
     public function loadById($id)
     {
         if (!is_numeric($id)) {