[gitg/wip/notes] Show commit notes
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/notes] Show commit notes
- Date: Mon, 3 Nov 2014 21:13:15 +0000 (UTC)
commit f45a4106b975303d0795a216db1e444376999e79
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Nov 3 21:21:47 2014 +0100
Show commit notes
libgitg/gitg-commit.vala | 28 ++++++++++++++++++++++++++++
libgitg/gitg-diff-view-request-diff.vala | 18 ++++++++++++++++--
libgitg/resources/diff-view.html | 1 +
libgitg/resources/diff-view.js | 6 ++++++
4 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 2aba60d..dc1ab25 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -169,6 +169,34 @@ public class Commit : Ggit.Commit
return diff;
}
+
+ public SList<Ggit.Note> get_notes()
+ {
+ SList<Ggit.Note> notes = new SList<Ggit.Note>();
+
+ var repo = get_owner();
+
+ var parents = get_parents();
+
+ for (var i = 0; i < parents.size(); ++i)
+ {
+ var parent_id = parents.get_id(i);
+
+ try
+ {
+ var note = repo.read_note(null, parent_id);
+ if (note != null)
+ {
+ notes.prepend(note);
+ }
+ }
+ catch (Error e) {}
+ }
+
+ notes.reverse();
+
+ return notes;
+ }
}
}
diff --git a/libgitg/gitg-diff-view-request-diff.vala b/libgitg/gitg-diff-view-request-diff.vala
index 02851c5..325b331 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,20 @@ namespace Gitg
builder.set_member_name("author");
signature_to_json(builder, commit.get_author());
+ var notes = commit.get_notes();
+
+ if (notes.length() > 0)
+ {
+ builder.set_member_name("notes");
+ foreach (Ggit.Note note in notes)
+ {
+ builder.begin_object();
+ builder.set_member_name("note");
+ builder.add_string_value(note.get_message());
+ builder.end_object();
+ }
+ }
+
builder.end_object();
}
diff --git a/libgitg/resources/diff-view.html b/libgitg/resources/diff-view.html
index 8d0012f..865bf36 100644
--- a/libgitg/resources/diff-view.html
+++ b/libgitg/resources/diff-view.html
@@ -41,6 +41,7 @@
<span class="date" data-id="date"></span>
</p>
<p class="message" data-id="message"></p>
+ <p class="notes" data-id="notes"></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..8d8a0b5 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -150,6 +150,12 @@ function write_commit(content, commit)
// Message
elems.message.text(prettify_message(commit.message));
+ // Notes
+ for (note in commit.notes)
+ {
+ elems.notes.text(note);
+ }
+
// Sha1
elems.sha1.text(commit.id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]