Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-05-17 17:19:25 +0000
committerKevin Sawicki2011-05-17 17:19:25 +0000
commit4debccab7b75998c47f3e367412dded667ce3f47 (patch)
treee4dfeef236902b91ba494c793c8b04f2c87cd48c /org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core
parentab16916d510898ce61f3675fa013ac57995adb23 (diff)
downloadegit-github-4debccab7b75998c47f3e367412dded667ce3f47.tar.gz
egit-github-4debccab7b75998c47f3e367412dded667ce3f47.tar.xz
egit-github-4debccab7b75998c47f3e367412dded667ce3f47.zip
Support creating public and private Gists from GitHub menu.
Change-Id: I5277bc907bb33a5fce206264e0e29396a877ffa4 Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core')
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java15
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java3
2 files changed, 6 insertions, 12 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
index 09609f7e..833f349a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttachmentHandler.java
@@ -13,6 +13,7 @@ package org.eclipse.mylyn.internal.github.core.gist;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.Collections;
import org.eclipse.core.runtime.CoreException;
@@ -20,7 +21,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.github.core.Gist;
import org.eclipse.egit.github.core.GistFile;
import org.eclipse.egit.github.core.client.GitHubClient;
-import org.eclipse.egit.github.core.client.GitHubRequest;
import org.eclipse.egit.github.core.service.GistService;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
@@ -62,19 +62,12 @@ public class GistAttachmentHandler extends AbstractTaskAttachmentHandler {
public InputStream getContent(TaskRepository repository, ITask task,
TaskAttribute attachmentAttribute, IProgressMonitor monitor)
throws CoreException {
- GitHubClient client = new GitHubClient();
- AuthenticationCredentials credentials = repository
- .getCredentials(AuthenticationType.REPOSITORY);
- if (credentials != null)
- client.setCredentials(credentials.getUserName(),
- credentials.getPassword());
-
TaskAttribute urlAttribute = attachmentAttribute
.getAttribute(GistAttribute.RAW_FILE_URL.getId());
try {
- GitHubRequest request = new GitHubRequest();
- request.setUri(urlAttribute.getValue());
- return client.getStream(request);
+ if (urlAttribute == null)
+ throw new IOException("Unable to obtain raw file URL from Gist"); //$NON-NLS-1$
+ return new URL(urlAttribute.getValue()).openStream();
} catch (IOException e) {
throw new CoreException(GitHub.createErrorStatus(e));
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
index f92c6d1a..11f08457 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java
@@ -84,7 +84,8 @@ public class GistConnector extends AbstractRepositoryConnector {
* @see org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector#canCreateNewTask(org.eclipse.mylyn.tasks.core.TaskRepository)
*/
public boolean canCreateNewTask(TaskRepository repository) {
- return true;
+ // Gists are created from menu actions on files and text selections
+ return false;
}
/**

Back to the top