aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-20 17:43:31 (EDT)
committerChris Aniszczyk2011-04-21 11:14:59 (EDT)
commit3d4fac7dfe6c6defcbac67e5096f88280d98d396 (patch)
treeebf3a2ee9777674f612a58716d1babcf61b501fa
parentc699e5fc0e24fb0f3b49c6d1d30d59dd1f6bfb2a (diff)
downloadegit-github-3d4fac7dfe6c6defcbac67e5096f88280d98d396.zip
egit-github-3d4fac7dfe6c6defcbac67e5096f88280d98d396.tar.gz
egit-github-3d4fac7dfe6c6defcbac67e5096f88280d98d396.tar.bz2
Add repository class that holds owner and namerefs/changes/86/3186/2
This allows conversion between a repository url and the repository owner and name required for API calls. Change-Id: Id96f529d6170b15c492398e715d78125969fb27d Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHub.java119
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java57
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java15
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Repository.java90
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java5
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositorySettingsPage.java33
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java6
7 files changed, 236 insertions, 89 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHub.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHub.java
index 708f39c..ac4b84a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHub.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHub.java
@@ -20,77 +20,146 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+/**
+ * GitHub class
+ */
public class GitHub {
+
+ /** BUNDLE_ID */
public static final String BUNDLE_ID = "org.eclipse.mylyn.github.core";
+
+ /** CONNECTOR_KIND */
public static final String CONNECTOR_KIND = "github";
+ /** HTTP_WWW_GITHUB_ORG */
public static final String HTTP_WWW_GITHUB_ORG = "http://www.github.org";
+
+ /** HTTP_GITHUB_COM */
public static final String HTTP_GITHUB_COM = "http://github.com";
- public static final Pattern URL_PATTERN = Pattern.compile("(?:"+Pattern.quote(HTTP_WWW_GITHUB_ORG)+"|"+Pattern.quote(HTTP_GITHUB_COM)+")/([^/]+)/([^/]+)");
+ /** URL_PATTERN */
+ public static final Pattern URL_PATTERN = Pattern.compile("(?:"
+ + Pattern.quote(HTTP_WWW_GITHUB_ORG) + "|"
+ + Pattern.quote(HTTP_GITHUB_COM) + ")/([^/]+)/([^/]+)");
+ /**
+ * Create status of severity with message
+ *
+ * @param severity
+ * @param message
+ * @return status
+ */
public static IStatus createStatus(int severity, String message) {
return new Status(severity, BUNDLE_ID, message);
}
+ /**
+ * Create status of severity with message and throwable
+ *
+ * @param severity
+ * @param message
+ * @param e
+ * @return status
+ */
public static IStatus createStatus(int severity, String message, Throwable e) {
return new Status(severity, BUNDLE_ID, message, e);
}
+ /**
+ * Create error status from message
+ *
+ * @param message
+ * @return status
+ */
public static IStatus createErrorStatus(String message) {
return createStatus(IStatus.ERROR, message);
}
+ /**
+ * Create error status from message and throwable
+ *
+ * @param message
+ * @param t
+ * @return status
+ */
public static IStatus createErrorStatus(String message, Throwable t) {
return createStatus(IStatus.ERROR, message, t);
}
+ /**
+ * Create error status from throwable
+ *
+ * @param e
+ * @return status
+ */
public static IStatus createErrorStatus(Throwable e) {
- return createStatus(IStatus.ERROR, "Unexpected error: "
- + e.getMessage(), e);
+ return createStatus(IStatus.ERROR,
+ "Unexpected error: " + e.getLocalizedMessage(), e);
}
+ /**
+ * Get log
+ *
+ * @return log
+ */
public static ILog getLog() {
return Platform.getLog(Platform.getBundle(BUNDLE_ID));
}
-
- public static void logError(String message,Throwable t) {
+
+ /**
+ * Log message and throwable as error status
+ *
+ * @param message
+ * @param t
+ */
+ public static void logError(String message, Throwable t) {
getLog().log(createErrorStatus(message, t));
}
-
+
+ /**
+ * Log throwable as error status
+ *
+ * @param t
+ */
public static void logError(Throwable t) {
getLog().log(createErrorStatus(t.getMessage(), t));
}
- public static String computeTaskRepositoryUser(String repositoryUrl) {
+ /**
+ * Get repository for url
+ *
+ * @param repositoryUrl
+ * @return repository or null if not present in url
+ */
+ public static Repository getRepository(String repositoryUrl) {
Matcher matcher = URL_PATTERN.matcher(repositoryUrl);
- if (matcher.matches()) {
- return matcher.group(1);
- }
- return null;
+ return matcher.matches() ? new Repository(matcher.group(1),
+ matcher.group(2)) : null;
}
- public static String computeTaskRepositoryProject(String repositoryUrl) {
- Matcher matcher = URL_PATTERN.matcher(repositoryUrl);
- if (matcher.matches()) {
- return matcher.group(2);
- }
- return null;
- }
-
/**
- * uses github.com
+ * Create url with github.com host
+ *
+ * @param user
+ * @param project
+ * @return url
+ *
* @see #createGitHubUrlAlternate(String, String)
*/
- public static String createGitHubUrl(String user,String project) {
- return HTTP_GITHUB_COM+'/'+user+'/'+project;
+ public static String createGitHubUrl(String user, String project) {
+ return HTTP_GITHUB_COM + '/' + user + '/' + project;
}
/**
- * Uses www.github.org
+ * Create url with github.org host
+ *
+ * @param user
+ * @param project
+ * @return url
+ *
* @see #createGitHubUrl(String, String)
*/
- public static String createGitHubUrlAlternate(String user,String project) {
- return HTTP_WWW_GITHUB_ORG+'/'+user+'/'+project;
+ public static String createGitHubUrlAlternate(String user, String project) {
+ return HTTP_WWW_GITHUB_ORG + '/' + user + '/' + project;
}
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java
index ec5a643..5a7a6f2 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubRepositoryConnector.java
@@ -95,14 +95,12 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
public List<Label> refreshLabels(TaskRepository repository)
throws CoreException {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- String user = GitHub.computeTaskRepositoryUser(repository
- .getRepositoryUrl());
- String project = GitHub.computeTaskRepositoryProject(repository
- .getRepositoryUrl());
+ Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
GitHubClient client = createClient(repository);
LabelService service = new LabelService(client);
try {
- List<Label> labels = service.getLabels(user, project);
+ List<Label> labels = service.getLabels(repo.getOwner(),
+ repo.getName());
Collections.sort(labels, new LabelComparator());
this.repositoryLabels.put(repository, labels);
return labels;
@@ -147,18 +145,15 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
public List<Milestone> refreshMilestones(TaskRepository repository)
throws CoreException {
Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
- String user = GitHub.computeTaskRepositoryUser(repository
- .getRepositoryUrl());
- String project = GitHub.computeTaskRepositoryProject(repository
- .getRepositoryUrl());
+ Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
GitHubClient client = createClient(repository);
MilestoneService service = new MilestoneService(client);
try {
List<Milestone> milestones = new LinkedList<Milestone>();
- milestones.addAll(service.getMilestones(user, project,
- IssueService.STATE_OPEN));
- milestones.addAll(service.getMilestones(user, project,
- IssueService.STATE_CLOSED));
+ milestones.addAll(service.getMilestones(repo.getOwner(),
+ repo.getName(), IssueService.STATE_OPEN));
+ milestones.addAll(service.getMilestones(repo.getOwner(),
+ repo.getName(), IssueService.STATE_CLOSED));
this.repositoryMilestones.put(repository, milestones);
return milestones;
} catch (IOException e) {
@@ -249,9 +244,8 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
monitor.beginTask(Messages.GitHubRepositoryConnector_TaskQuerying,
statuses.size());
try {
- String user = GitHub.computeTaskRepositoryUser(repository.getUrl());
- String project = GitHub.computeTaskRepositoryProject(repository
- .getUrl());
+ Repository repo = GitHub.getRepository(repository
+ .getRepositoryUrl());
GitHubClient client = createClient(repository);
IssueService service = new IssueService(client);
@@ -282,13 +276,14 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
for (String status : statuses) {
filterData.put(IssueService.FILTER_STATE, status);
- List<Issue> issues = service.getIssues(user, project,
- filterData);
+ List<Issue> issues = service.getIssues(repo.getOwner(),
+ repo.getName(), filterData);
// collect task data
for (Issue issue : issues) {
TaskData taskData = taskDataHandler.createTaskData(
- repository, monitor, user, project, issue);
+ repository, monitor, repo.getOwner(),
+ repo.getName(), issue);
taskData.setPartial(true);
collector.accept(taskData);
}
@@ -307,21 +302,20 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
@Override
public TaskData getTaskData(TaskRepository repository, String taskId,
IProgressMonitor monitor) throws CoreException {
-
- String user = GitHub.computeTaskRepositoryUser(repository.getUrl());
- String project = GitHub.computeTaskRepositoryProject(repository
- .getUrl());
+ Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
try {
GitHubClient client = createClient(repository);
IssueService service = new IssueService(client);
- Issue issue = service.getIssue(user, project, taskId);
+ Issue issue = service.getIssue(repo.getOwner(), repo.getName(),
+ taskId);
List<Comment> comments = null;
if (issue.getComments() > 0) {
- comments = service.getComments(user, project, taskId);
+ comments = service.getComments(repo.getOwner(), repo.getName(),
+ taskId);
}
TaskData taskData = taskDataHandler.createTaskData(repository,
- monitor, user, project, issue, comments);
+ monitor, repo.getOwner(), repo.getName(), issue, comments);
return taskData;
} catch (IOException e) {
@@ -332,7 +326,8 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
@Override
public String getRepositoryUrlFromTaskUrl(String taskFullUrl) {
if (taskFullUrl != null) {
- Matcher matcher = Pattern.compile("(http://.+?)/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
+ Matcher matcher = Pattern.compile(
+ "(http://.+?)/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
if (matcher.matches()) {
return matcher.group(1);
}
@@ -343,7 +338,8 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
@Override
public String getTaskIdFromTaskUrl(String taskFullUrl) {
if (taskFullUrl != null) {
- Matcher matcher = Pattern.compile(".+?/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
+ Matcher matcher = Pattern
+ .compile(".+?/issues/issue/([^/]+)").matcher(taskFullUrl); //$NON-NLS-1$
if (matcher.matches()) {
return matcher.group(1);
}
@@ -353,7 +349,7 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
@Override
public String getTaskUrl(String repositoryUrl, String taskId) {
- return repositoryUrl+"/issues/issue/"+taskId; //$NON-NLS-1$
+ return repositoryUrl + "/issues/issue/" + taskId; //$NON-NLS-1$
}
@Override
@@ -392,7 +388,8 @@ public class GitHubRepositoryConnector extends AbstractRepositoryConnector {
public void updateTaskFromTaskData(TaskRepository taskRepository,
ITask task, TaskData taskData) {
if (!taskData.isNew()) {
- task.setUrl(getTaskUrl(taskRepository.getUrl(), taskData.getTaskId()));
+ task.setUrl(getTaskUrl(taskRepository.getUrl(),
+ taskData.getTaskId()));
}
new TaskMapper(taskData).applyTo(task);
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
index babfda5..fb7d649 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
@@ -378,15 +378,15 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
IProgressMonitor monitor) throws CoreException {
String taskId = taskData.getTaskId();
Issue issue = createIssue(taskData);
- String user = GitHub.computeTaskRepositoryUser(repository.getUrl());
- String repo = GitHub.computeTaskRepositoryProject(repository.getUrl());
+ Repository repo = GitHub.getRepository(repository.getRepositoryUrl());
try {
GitHubClient client = GitHubRepositoryConnector
.createClient(repository);
IssueService service = new IssueService(client);
if (taskData.isNew()) {
issue.setState(IssueService.STATE_OPEN);
- issue = service.createIssue(user, repo, issue);
+ issue = service.createIssue(repo.getOwner(), repo.getName(),
+ issue);
taskId = Integer.toString(issue.getNumber());
} else {
@@ -394,10 +394,11 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
String comment = getAttributeValue(taskData,
GitHubTaskAttributes.COMMENT_NEW);
if (comment != null && comment.length() > 0)
- service.createComment(user, repo, taskId, comment);
+ service.createComment(repo.getOwner(), repo.getName(),
+ taskId, comment);
- updateLabels(user, repo, client, repository, taskData,
- oldAttributes);
+ updateLabels(repo.getOwner(), repo.getName(), client,
+ repository, taskData, oldAttributes);
// Handle state change
TaskAttribute operationAttribute = taskData.getRoot()
@@ -418,7 +419,7 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
}
}
- service.editIssue(user, repo, issue);
+ service.editIssue(repo.getOwner(), repo.getName(), issue);
}
return new RepositoryResponse(
taskData.isNew() ? ResponseKind.TASK_CREATED
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Repository.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Repository.java
new file mode 100644
index 0000000..5cf1fad
--- /dev/null
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Repository.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.github.internal;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * GitHub Repository class.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class Repository {
+
+ private String owner;
+ private String name;
+
+ /**
+ * Create repository with owner and name
+ *
+ * @param owner
+ * @param name
+ */
+ public Repository(String owner, String name) {
+ Assert.isNotNull(owner, "Owner cannot be null"); //$NON-NLS-1$
+ Assert.isLegal(owner.length() > 0, "Owner cannot be empty"); //$NON-NLS-1$
+ Assert.isNotNull(name, "Name cannot be null"); //$NON-NLS-1$
+ Assert.isLegal(name.length() > 0, "Name cannot be empty"); //$NON-NLS-1$
+
+ this.owner = owner;
+ this.name = name;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getId().hashCode();
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+ else if (obj instanceof Repository)
+ return getId().equals(((Repository) obj).getId());
+ else
+ return false;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return getId();
+ }
+
+ /**
+ * Get unique identifier for repository
+ *
+ * @return id
+ */
+ public String getId() {
+ return this.owner + '/' + this.name;
+ }
+
+ /**
+ * @return owner
+ */
+ public String getOwner() {
+ return this.owner;
+ }
+
+ /**
+ * @return name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java
index 5791976..9cc52c0 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryConnectorUI.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.github.internal.GitHub;
import org.eclipse.mylyn.github.internal.GitHubRepositoryConnector;
+import org.eclipse.mylyn.github.internal.Repository;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -127,7 +128,9 @@ public class GitHubRepositoryConnectorUI extends AbstractRepositoryConnectorUi {
if (project == null && user != null) {
// same project name, different user
String url = repository.getUrl();
- project = GitHub.computeTaskRepositoryProject(url);
+ Repository repo = GitHub.getRepository(url);
+ if (repo != null)
+ project = repo.getName();
}
TaskRepository taskRepository = null;
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositorySettingsPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositorySettingsPage.java
index 1e1d78d..77749bc 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositorySettingsPage.java
@@ -15,7 +15,6 @@ package org.eclipse.mylyn.github.ui.internal;
import java.io.IOException;
import java.net.URL;
import java.text.MessageFormat;
-import java.util.regex.Matcher;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -27,6 +26,7 @@ import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.github.internal.GitHub;
import org.eclipse.mylyn.github.internal.GitHubClient;
import org.eclipse.mylyn.github.internal.IssueService;
+import org.eclipse.mylyn.github.internal.Repository;
import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
@@ -83,10 +83,10 @@ public class GitHubRepositorySettingsPage extends
protected void syncRepositoryLabel() {
if (syncLabel) {
String url = serverUrlCombo.getText();
- String user = GitHub.computeTaskRepositoryUser(url);
- String repo = GitHub.computeTaskRepositoryProject(url);
- if (user != null && repo != null)
- repositoryLabelEditor.setStringValue(user + '/' + repo);
+ Repository repo = GitHub.getRepository(url);
+ if (repo != null)
+ repositoryLabelEditor.setStringValue(repo.getOwner() + '/'
+ + repo.getName());
}
}
@@ -139,16 +139,6 @@ public class GitHubRepositorySettingsPage extends
Messages.GitHubRepositorySettingsPage_TaskValidating,
100);
try {
- String urlText = repository.getUrl();
- Matcher urlMatcher = GitHub.URL_PATTERN
- .matcher(urlText == null ? "" : urlText); //$NON-NLS-1$
- if (!urlMatcher.matches()) {
- setStatus(GitHubUi
- .createErrorStatus(Messages.GitHubRepositorySettingsPage_ErrorMalformedUrl));
- return;
- }
- monitor.worked(20);
-
monitor.subTask(Messages.GitHubRepositorySettingsPage_TaskContactingServer);
try {
AuthenticationCredentials auth = repository
@@ -158,13 +148,10 @@ public class GitHubRepositorySettingsPage extends
client.setCredentials(auth.getUserName(),
auth.getPassword());
IssueService service = new IssueService(client);
- String user = GitHub
- .computeTaskRepositoryUser(repository.getUrl());
- String project = GitHub
- .computeTaskRepositoryProject(repository
- .getUrl());
- monitor.worked(20);
- service.getIssues(user, project, null);
+ Repository repo = GitHub.getRepository(repository
+ .getRepositoryUrl());
+ monitor.worked(50);
+ service.getIssues(repo.getOwner(), repo.getName(), null);
} catch (IOException e) {
String message = MessageFormat
.format(Messages.GitHubRepositorySettingsPage_StatusError,
@@ -190,7 +177,7 @@ public class GitHubRepositorySettingsPage extends
if (url.startsWith("http://") || url.startsWith("https://")) //$NON-NLS-1$ //$NON-NLS-2$
try {
new URL(url);
- return true;
+ return GitHub.getRepository(url) != null;
} catch (IOException e) {
return false;
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java
index 5f4f0aa..9e8d795 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java
@@ -19,8 +19,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.github.internal.GistService;
-import org.eclipse.mylyn.github.internal.GitHub;
import org.eclipse.mylyn.github.internal.GitHubClient;
import org.eclipse.mylyn.github.ui.internal.GitHubUi;
import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
@@ -98,8 +98,8 @@ public class GistRepositorySettingsPage extends AbstractRepositorySettingsPage {
GitHubClient client = GistConnector
.createClient(repository);
GistService service = new GistService(client);
- String user = GitHub
- .computeTaskRepositoryUser(repository.getUrl());
+ String user = repository.getCredentials(
+ AuthenticationType.REPOSITORY).getUserName();
monitor.worked(20);
service.getGists(user);
} catch (IOException e) {