{"thread":{"id":"11755","subject":"[EGIT PATCH 1/2] Show committer and parent commit(s) on the revision detail viewer.","startedAt":"2008-01-27T02:29:27Z","lastAt":"2008-01-30T21:19:48Z","messageCount":2,"participants":["Roger C. Soares","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"66656","messageId":"1201400967-5860-1-git-send-email-rogersoares@intelinet.com.br","threadId":"11755","inReplyTo":null,"subject":"[EGIT PATCH 1/2] Show committer and parent commit(s) on the revision detail viewer.","fromName":"Roger C. Soares","fromEmail":"rogersoares@intelinet.com.br","sentAt":"2008-01-27T02:29:27Z","receivedAt":"2008-01-27T02:29:27Z","isPatch":true,"sender":{"key":"rogersoares@intelinet.com.br","avatar":null},"body":"Signed-off-by: Roger C. Soares <rogersoares@intelinet.com.br>\n---\nHi Robin,\n\nHere it goes again.\n\n[]s,\nRoger.\n\n .../src/org/spearce/egit/ui/GitHistoryPage.java    |   56 +++++++++++++++++---\n 1 files changed, 49 insertions(+), 7 deletions(-)\n\ndiff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java\nindex 649df3f..289331c 100644\n--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java\n+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java\n@@ -88,7 +88,9 @@ import org.spearce.egit.core.internal.mapping.GitFileHistoryProvider;\n import org.spearce.egit.core.internal.mapping.GitFileRevision;\n import org.spearce.egit.core.project.RepositoryMapping;\n import org.spearce.egit.ui.internal.actions.GitCompareRevisionAction;\n+import org.spearce.jgit.lib.Commit;\n import org.spearce.jgit.lib.ObjectId;\n+import org.spearce.jgit.lib.PersonIdent;\n import org.spearce.jgit.lib.Tag;\n import org.spearce.jgit.lib.TopologicalSorter;\n import org.spearce.jgit.lib.Repository.StGitPatch;\n@@ -221,12 +223,13 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\t\tif(selection2.length == 1) {\n \t\t\t\t\t// if the table item is not visible in the UI and it's selected via keyboard\n \t\t\t\t\t// this listener is called before the listener that sets the item data.\n-\t\t\t\t\tif(selection2[0] == null) {\n+\t\t\t\t\tIFileRevision revision = selection2[0];\n+\t\t\t\t\tif(revision == null) {\n \t\t\t\t\t\tint ix = table.getSelectionIndex();\n-\t\t\t\t\t\tGitFileRevision revision = (GitFileRevision) fileRevisions.get(ix);\n+\t\t\t\t\t\trevision = fileRevisions.get(ix);\n \t\t\t\t\t\tselection2[0] = revision;\n \t\t\t\t\t}\n-\t\t\t\t\tsetRevisionInfoTextViewers(selection2[0]);\n+\t\t\t\t\tsetRevisionInfoTextViewers((GitCommitFileRevision)revision);\n \t\t\t\t}\n \n \t\t\t\tcompareAction.setCurrentFileRevision(fileRevisions.get(0));\n@@ -554,7 +557,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\trevCommentTextViewer = new TextViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);\n \t}\n \n-\t/* private */void setRevisionInfoTextViewers(IFileRevision rev) {\n+\t/* private */void setRevisionInfoTextViewers(GitCommitFileRevision rev) {\n \t\tStringBuilder revisionInfo = new StringBuilder();\n \t\tif (appliedPatches != null) {\n \t\t\tString id = rev.getContentIdentifier();\n@@ -616,6 +619,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\t\t}\n \t\t\t}\n \t\t} catch (IOException e) {\n+\t\t\t// TODO: better error handling.\n \t\t\te.printStackTrace();\n \t\t}\n \n@@ -673,10 +677,31 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\t\te.printStackTrace();\n \t\t}\n \n+\t\tCommit commit = rev.getCommit();\n \t\trevisionInfo.append(\"\\nAuthor: \");\n-\t\trevisionInfo.append(rev.getAuthor());\n-\t\trevisionInfo.append(\"\\nDate: \");\n-\t\trevisionInfo.append(DATETIMETZ_FORMAT.format(new Date(rev.getTimestamp())));\n+\t\trevisionInfo.append(formatPersonIdentForRevInfo(commit.getAuthor()));\n+\t\trevisionInfo.append(\"\\nCommitter: \");\n+\t\trevisionInfo.append(formatPersonIdentForRevInfo(commit.getCommitter()));\n+\t\tif(commit.getParentIds() != null) {\n+\t\t\tfor(ObjectId pid : commit.getParentIds()) {\n+\t\t\t\trevisionInfo.append(\"\\nParent: \");\n+\t\t\t\trevisionInfo.append(pid.toString());\n+\t\t\t\ttry {\n+\t\t\t\t\tCommit pc = repositoryMapping.getRepository().mapCommit(pid);\n+\t\t\t\t\trevisionInfo.append(\" (\");\n+\t\t\t\t\tString cmesg = pc.getMessage();\n+\t\t\t\t\tint enterIndex = cmesg.indexOf(\"\\n\");\n+\t\t\t\t\tif(enterIndex > 0) {\n+\t\t\t\t\t\tcmesg = cmesg.substring(0, enterIndex);\n+\t\t\t\t\t}\n+\t\t\t\t\trevisionInfo.append(cmesg);\n+\t\t\t\t\trevisionInfo.append(\" )\");\n+\t\t\t\t} catch (IOException e) {\n+\t\t\t\t\t// TODO: better error handling.\n+\t\t\t\t\te.printStackTrace();\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n \n \t\tString comment = rev.getComment();\n \t\trevDetailTextViewer.setDocument(new Document(revisionInfo.toString()));\n@@ -691,6 +716,23 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,\n \t\tif (workbenchPageSite != null) {\n \t\t\tworkbenchPageSite.getActionBars().getStatusLineManager().setMessage(comment);\n \t\t}\n+\n+\t}\n+\n+\tprivate String formatPersonIdentForRevInfo(PersonIdent p) {\n+\t\tStringBuilder sb = new StringBuilder();\n+\t\tsb.append(p.getName());\n+\t\tif(p.getEmailAddress() != null) {\n+\t\t\tsb.append(\" <\");\n+\t\t\tsb.append(p.getEmailAddress());\n+\t\t\tsb.append(\">\");\n+\t\t}\n+\t\tif(p.getWhen() != null) {\n+\t\t\tsb.append(\" \");\n+\t\t\tsb.append(DATETIMETZ_FORMAT.format(p.getWhen()));\n+\t\t}\n+\n+\t\treturn sb.toString();\n \t}\n \n \t/* private */void cleanRevisionInfoTextViewers() {\n-- \n1.5.3.7\n"},{"id":"66929","messageId":"200801302219.50203.robin.rosenberg@dewire.com","threadId":"11755","inReplyTo":"1201400967-5860-1-git-send-email-rogersoares@intelinet.com.br","subject":"Re: [EGIT PATCH 1/2] Show committer and parent commit(s) on the revision detail viewer.","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2008-01-30T21:19:48Z","receivedAt":"2008-01-30T21:19:48Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndagen den 27 januari 2008 skrev Roger C. Soares:\n> Signed-off-by: Roger C. Soares <rogersoares@intelinet.com.br>\n> ---\n> Hi Robin,\n> \n> Here it goes again.\n\nPushed. Thank you.\n\n-- robin\n"}]}