Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 198563 Details for
Bug 350314
[git][log] Support gravatar images
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to include image link in commit author info
serverpatch.txt (text/plain), 3.59 KB, created by
John Arthorne
on 2011-06-24 14:14:43 EDT
(
hide
)
Description:
Patch to include image link in commit author info
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2011-06-24 14:14:43 EDT
Size:
3.59 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java b/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java >index e441634..5eae98b 100644 >--- a/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java >+++ b/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java >@@ -14,6 +14,8 @@ import java.io.File; > import java.io.IOException; > import java.net.URI; > import java.net.URISyntaxException; >+import java.security.MessageDigest; >+import java.security.NoSuchAlgorithmException; > import java.util.*; > import java.util.Map.Entry; > import javax.servlet.ServletException; >@@ -261,10 +263,15 @@ public class GitCommitHandlerV1 extends ServletResourceHandler<String> { > commit.put(ProtocolConstants.KEY_CONTENT_LOCATION, createCommitLocation(baseLocation, revCommit.getName(), "parts=body")); //$NON-NLS-1$ > commit.put(GitConstants.KEY_DIFF, createDiffLocation(baseLocation, revCommit.getName(), null, null, isRoot)); > commit.put(ProtocolConstants.KEY_NAME, revCommit.getName()); >- commit.put(GitConstants.KEY_AUTHOR_NAME, revCommit.getAuthorIdent().getName()); >- commit.put(GitConstants.KEY_AUTHOR_EMAIL, revCommit.getAuthorIdent().getEmailAddress()); >- commit.put(GitConstants.KEY_COMMITTER_NAME, revCommit.getCommitterIdent().getName()); >- commit.put(GitConstants.KEY_COMMITTER_EMAIL, revCommit.getCommitterIdent().getEmailAddress()); >+ PersonIdent author = revCommit.getAuthorIdent(); >+ commit.put(GitConstants.KEY_AUTHOR_NAME, author.getName()); >+ commit.put(GitConstants.KEY_AUTHOR_EMAIL, author.getEmailAddress()); >+ String authorImage = getImageLink(author.getEmailAddress()); >+ if (authorImage != null) >+ commit.put("AuthorImage", authorImage); >+ PersonIdent committer = revCommit.getCommitterIdent(); >+ commit.put(GitConstants.KEY_COMMITTER_NAME, committer.getName()); >+ commit.put(GitConstants.KEY_COMMITTER_EMAIL, committer.getEmailAddress()); > commit.put(GitConstants.KEY_COMMIT_TIME, ((long) revCommit.getCommitTime()) * 1000 /* time in milliseconds */); > commit.put(GitConstants.KEY_COMMIT_MESSAGE, revCommit.getFullMessage()); > commit.put(ProtocolConstants.KEY_CHILDREN, toJSON(getTagsForCommit(db, revCommit))); >@@ -307,6 +314,33 @@ public class GitCommitHandlerV1 extends ServletResourceHandler<String> { > return commit; > } > >+ /** >+ * Returns the URL of an image corresponding to the given email address. >+ * Currently this is implemented using gravatar. >+ */ >+ private String getImageLink(String emailAddress) { >+ MessageDigest digest; >+ try { >+ digest = MessageDigest.getInstance("MD5"); //$NON-NLS-1$ >+ } catch (NoSuchAlgorithmException e) { >+ //without MD5 we can't compute gravatar hashes >+ return null; >+ } >+ digest.update(emailAddress.trim().toLowerCase().getBytes()); >+ byte[] digestValue = digest.digest(); >+ StringBuffer result = new StringBuffer("http://www.gravatar.com/avatar/"); //$NON-NLS-1$ >+ for (int i = 0; i < digestValue.length; i++) { >+ String current = Integer.toHexString((digestValue[i] & 0xFF)); >+ //left pad with zero >+ if (current.length() == 1) >+ result.append('0'); >+ result.append(current); >+ } >+ //Default to "mystery man" icon if the user has no gravatar >+ result.append("?d=mm"); //$NON-NLS-1$ >+ return result.toString(); >+ } >+ > private JSONArray toJSON(Map<String, Ref> revTags) throws JSONException { > JSONArray children = new JSONArray(); > for (Entry<String, Ref> revTag : revTags.entrySet()) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 350314
: 198563 |
198564