[gitg] Show committer in diff when differs from author



commit 28f7631be7d0d79302924e839aa46ed07fd92c3f
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sun Mar 15 10:56:49 2015 +0100

    Show committer in diff when differs from author

 libgitg/gitg-diff-view.vala                   |    1 +
 libgitg/resources/ui/diff-view/diff-view.css  |    5 ++++
 libgitg/resources/ui/diff-view/diff-view.html |    1 +
 libgitg/resources/ui/diff-view/diff-view.js   |   33 ++++++++++++++++++++++---
 4 files changed, 36 insertions(+), 4 deletions(-)
---
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index d340e0e..80112ce 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -252,6 +252,7 @@ namespace Gitg
                        strings.set_string_member("notes", _("Notes:"));
                        strings.set_string_member("parents", _("Parents:"));
                        strings.set_string_member("diff_against", _("Diff against:"));
+                       strings.set_string_member("committed_by", _("Committed by:"));
 
                        o.set_object_member("strings", strings);
 
diff --git a/libgitg/resources/ui/diff-view/diff-view.css b/libgitg/resources/ui/diff-view/diff-view.css
index 247b69c..09a278a 100644
--- a/libgitg/resources/ui/diff-view/diff-view.css
+++ b/libgitg/resources/ui/diff-view/diff-view.css
@@ -229,6 +229,11 @@ div.commit .date, div.commit .sha1 {
   font-size: 0.8em;
 }
 
+div.commit .committer {
+  font-size: 0.8em;
+  display: none;
+}
+
 div.commit .sha1 {
   font-family: monospace;
   text-align: right;
diff --git a/libgitg/resources/ui/diff-view/diff-view.html b/libgitg/resources/ui/diff-view/diff-view.html
index d2e5da0..070d4f1 100644
--- a/libgitg/resources/ui/diff-view/diff-view.html
+++ b/libgitg/resources/ui/diff-view/diff-view.html
@@ -41,6 +41,7 @@
           <img class="avatar" data-id="avatar" src="gitg-diff:/icon/avatar-default-symbolic?size=50"/>
           <p>
             <span class="author" data-id="author"></span><br/>
+            <span class="author committer" data-id="committed-by"></span>
             <span class="date" data-id="date"></span>
           </p>
           <p class="message" data-id="message"></p>
diff --git a/libgitg/resources/ui/diff-view/diff-view.js b/libgitg/resources/ui/diff-view/diff-view.js
index 7de845b..1d9d9ab 100644
--- a/libgitg/resources/ui/diff-view/diff-view.js
+++ b/libgitg/resources/ui/diff-view/diff-view.js
@@ -28,7 +28,8 @@ var settings = {
                loading_diff: 'Loading diff...',
                notes: 'Notes:',
                parents: 'Parents:',
-               diff_against: 'Diff against:'
+               diff_against: 'Diff against:',
+               committed_by: 'Committed by:'
        },
 };
 
@@ -149,14 +150,38 @@ function prettify_message(message)
        return escaped;
 }
 
+function author_to_html(author, prefix)
+{
+       var name = $('<span/>', {'class': 'author name'}).text(author.name);
+       var a = $('<a/>', {href: 'mailto:' + author.email}).text(author.email);
+
+       var ret = $('<span/>');
+
+       if (prefix)
+       {
+               ret.append($('<span/>').text(prefix + ' '));
+       }
+
+       return ret.append(name).append(' <').append(a).append('>');
+}
+
 function write_commit(content, commit)
 {
        var elems = get_commit_elements(content);
 
        // Author
-       var name = $('<span/>', {'class': 'author name'}).text(commit.author.name);
-       var a = $('<a/>', {href: 'mailto:' + commit.author.email}).text(commit.author.email);
-       elems.author.html($('<span/>').append(name).append(' <').append(a).append('>'));
+       elems.author.html(author_to_html(commit.author));
+
+       // Committer
+       if (commit.author.name !== commit.committer.name ||
+           commit.author.email !== commit.committer.email) {
+               elems['committed-by'].html(author_to_html(commit.committer, 
settings.strings.committed_by).append($('<br>')));
+               elems['committed-by'].show();
+       }
+       else
+       {
+               elems['committed-by'].hide();
+       }
 
        // Date
        elems.date.text(commit.author.time);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]