]> source.dussan.org Git - gitblit.git/commitdiff
Added GitNotes to the commitdiff page
authorJames Moger <james.moger@gitblit.com>
Wed, 18 Sep 2013 15:21:00 +0000 (11:21 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 18 Sep 2013 15:31:01 +0000 (11:31 -0400)
src/main/java/com/gitblit/wicket/pages/CommitDiffPage.html
src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java

index 7437d2ed0d72a4f251f8ee06419a493c675cc2f9..7fd3857fdb247701ea07e656aff0039072c10e8a 100644 (file)
        <!-- full message -->\r
        <div wicket:id="fullMessage">[commit message]</div>\r
 \r
+       <!--  git notes -->\r
+       <table class="gitnotes">\r
+               <tr wicket:id="notes">\r
+                       <td class="info">\r
+                               <table>\r
+                                       <tr><td><span wicket:id="refName"></span></td></tr>\r
+                                       <tr><td><span class="sha1" wicket:id="authorName"></span></td></tr>\r
+                                       <tr><td><span class="sha1" wicket:id="authorDate"></span></td></tr>\r
+                               </table>\r
+                               <!--  Note Author Gravatar -->\r
+                               <span style="vertical-align: top;" wicket:id="noteAuthorAvatar" />                              \r
+                       </td>\r
+                       <td class="message"><span class="sha1" wicket:id="noteContent"></span></td>\r
+               </tr>\r
+       </table>\r
+       \r
        <!-- commit legend -->\r
        <div class="hidden-phone" style="text-align:right;" wicket:id="commitLegend"></div>\r
        \r
        \r
        <!--  diff content -->\r
        <pre style="padding-top:10px;" wicket:id="diffText">[diff text]</pre>\r
+\r
+       <wicket:fragment wicket:id="fullPersonIdent">\r
+               <span wicket:id="personName"></span><span wicket:id="personAddress"></span>\r
+       </wicket:fragment>\r
+       \r
+       <wicket:fragment wicket:id="partialPersonIdent">\r
+               <span wicket:id="personName"></span>\r
+       </wicket:fragment>\r
        \r
 </wicket:extend>\r
 </body>\r
index 4c802d747b8519b70cf53e33074c9d5e650e0710..eb672164010f09d36b27f4eaf1b89e00d8fba3ba 100644 (file)
@@ -16,6 +16,7 @@
 package com.gitblit.wicket.pages;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.wicket.PageParameters;
@@ -29,8 +30,10 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 
+import com.gitblit.Constants;
 import com.gitblit.GitBlit;
 import com.gitblit.models.PathModel.PathChangeModel;
+import com.gitblit.models.GitNote;
 import com.gitblit.models.SubmoduleModel;
 import com.gitblit.utils.DiffUtils;
 import com.gitblit.utils.DiffUtils.DiffOutputType;
@@ -40,7 +43,9 @@ import com.gitblit.wicket.CacheControl.LastModified;
 import com.gitblit.wicket.WicketUtils;
 import com.gitblit.wicket.panels.CommitHeaderPanel;
 import com.gitblit.wicket.panels.CommitLegendPanel;
+import com.gitblit.wicket.panels.GravatarImage;
 import com.gitblit.wicket.panels.LinkPanel;
+import com.gitblit.wicket.panels.RefsPanel;
 
 @CacheControl(LastModified.BOOT)
 public class CommitDiffPage extends RepositoryPage {
@@ -77,6 +82,26 @@ public class CommitDiffPage extends RepositoryPage {
 
                addFullText("fullMessage", commit.getFullMessage());
 
+               // git notes
+               List<GitNote> notes = JGitUtils.getNotesOnCommit(r, commit);
+               ListDataProvider<GitNote> notesDp = new ListDataProvider<GitNote>(notes);
+               DataView<GitNote> notesView = new DataView<GitNote>("notes", notesDp) {
+                       private static final long serialVersionUID = 1L;
+
+                       public void populateItem(final Item<GitNote> item) {
+                               GitNote entry = item.getModelObject();
+                               item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));
+                               item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(),
+                                               Constants.SearchType.AUTHOR));
+                               item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
+                               item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
+                                               .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
+                               item.add(new Label("noteContent", GitBlit.self().processPlainCommitMessage(repositoryName,
+                                               entry.content)).setEscapeModelStrings(false));
+                       }
+               };
+               add(notesView.setVisible(notes.size() > 0));
+               
                // changed paths list
                List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);