[gitg/wip/notes] Show commit notes



commit a993f23a1b9fc1aabe5e2aa6b5a6168fbce02650
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Mon Nov 3 21:21:47 2014 +0100

    Show commit notes
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737141

 libgitg/gitg-commit.vala                 |   15 +++++++++++++++
 libgitg/gitg-diff-view-request-diff.vala |   11 +++++++++--
 libgitg/gitg-diff-view.vala              |    1 +
 libgitg/resources/diff-view.css          |    5 +++++
 libgitg/resources/diff-view.html         |    4 ++++
 libgitg/resources/diff-view.js           |   10 +++++++++-
 6 files changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 2aba60d..ab3576c 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -169,6 +169,21 @@ public class Commit : Ggit.Commit
 
                return diff;
        }
+
+       public Ggit.Note get_note()
+       {
+               Ggit.Note note = null;
+
+               var repo = get_owner();
+
+               try
+               {
+                       note = repo.read_note(null, get_id());
+               }
+               catch (Error e) {}
+
+               return note;
+       }
 }
 
 }
diff --git a/libgitg/gitg-diff-view-request-diff.vala b/libgitg/gitg-diff-view-request-diff.vala
index 02851c5..167b55f 100644
--- a/libgitg/gitg-diff-view-request-diff.vala
+++ b/libgitg/gitg-diff-view-request-diff.vala
@@ -29,7 +29,7 @@ namespace Gitg
 
                private DiffType d_diff_type;
                private Ggit.Diff? d_diff;
-               private Ggit.Commit? d_commit;
+               private Commit? d_commit;
 
                public DiffViewRequestDiff(DiffView? view, WebKit.URISchemeRequest request, Soup.URI uri)
                {
@@ -214,7 +214,7 @@ namespace Gitg
                        builder.end_object();
                }
 
-               private void commit_to_json(Json.Builder builder, Ggit.Commit commit)
+               private void commit_to_json(Json.Builder builder, Commit commit)
                {
                        builder.begin_object();
 
@@ -233,6 +233,13 @@ namespace Gitg
                        builder.set_member_name("author");
                        signature_to_json(builder, commit.get_author());
 
+                       var note = commit.get_note();
+                       if (note != null)
+                       {
+                               builder.set_member_name("note");
+                               builder.add_string_value(note.get_message());
+                       }
+
                        builder.end_object();
                }
 
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 588cad5..f2a7c81 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -229,6 +229,7 @@ namespace Gitg
                        strings.set_string_member("stage", _("stage"));
                        strings.set_string_member("unstage", _("unstage"));
                        strings.set_string_member("loading_diff", _("Loading diff…"));
+                       strings.set_string_member("notes", _("Notes:"));
 
                        o.set_object_member("strings", strings);
 
diff --git a/libgitg/resources/diff-view.css b/libgitg/resources/diff-view.css
index c175a33..1a80e80 100644
--- a/libgitg/resources/diff-view.css
+++ b/libgitg/resources/diff-view.css
@@ -228,6 +228,11 @@ div.commit .message {
   margin-bottom: 5px;
 }
 
+div.commit .note_message {
+  margin-left: 5px;
+  margin-bottom: 5px;
+}
+
 a {
   color: #3465a4;
 }
diff --git a/libgitg/resources/diff-view.html b/libgitg/resources/diff-view.html
index 8d0012f..5929f4d 100644
--- a/libgitg/resources/diff-view.html
+++ b/libgitg/resources/diff-view.html
@@ -41,6 +41,10 @@
             <span class="date" data-id="date"></span>
           </p>
           <p class="message" data-id="message"></p>
+          <p>
+            <span class="notes" data-id="notes"></span><br/>
+            <span class="note_message" data-id="note_message"></span>
+          </p>
           <div class="sha1" data-id="sha1"></div>
         </div>
       </div>
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index 5192bb3..f5e249d 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -24,7 +24,8 @@ var settings = {
        strings: {
                stage: 'stage',
                unstage: 'unstage',
-               loading_diff: 'Loading diff...'
+               loading_diff: 'Loading diff...',
+               notes: 'Notes:'
        },
 };
 
@@ -150,6 +151,13 @@ function write_commit(content, commit)
        // Message
        elems.message.text(prettify_message(commit.message));
 
+       // Notes
+       if (commit.hasOwnProperty('note'))
+       {
+               elems.notes.text(settings.strings.notes);
+               elems.note_message.text(commit.note);
+       }
+
        // Sha1
        elems.sha1.text(commit.id);
 


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