aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-04-04 18:25:09 (EDT)
committerChristian Trutz2011-04-05 17:41:58 (EDT)
commit728bc02d49b7fda5d6b97078d418b69ebab2cb3c (patch)
treeb8d59eb627d7de6f0964a9aba0fccc9f447c52bd
parentb4735b0aa33c81af8d7af074ccd68d9b5f224233 (diff)
downloadegit-github-728bc02d49b7fda5d6b97078d418b69ebab2cb3c.zip
egit-github-728bc02d49b7fda5d6b97078d418b69ebab2cb3c.tar.gz
egit-github-728bc02d49b7fda5d6b97078d418b69ebab2cb3c.tar.bz2
Add comment support to GitHub task editorrefs/changes/03/3003/3
Adding new comments on existing issues is implemented now. Bug: 340901 Change-Id: I896ace16cc698e4b51ebb61e5a2732a874789dfb Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java12
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubService.java36
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java3
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java16
4 files changed, 61 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
index 9a989e0..0d581a0 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
@@ -26,6 +26,8 @@ public class GitHubIssue {
private String body;
+ private String comment_new;
+
/**
* open, closed
*/
@@ -53,6 +55,7 @@ public class GitHubIssue {
this.user = user;
this.title = title;
this.body = body;
+ this.comment_new = null;
}
/**
@@ -63,6 +66,7 @@ public class GitHubIssue {
this.user = "";
this.title = "";
this.body = "";
+ this.comment_new = null;
}
/**
@@ -169,4 +173,12 @@ public class GitHubIssue {
public void setClosed_at(String closed_at) {
this.closed_at = closed_at;
}
+
+ public String getComment_new() {
+ return comment_new;
+ }
+
+ public void setComment_new(String comment_new) {
+ this.comment_new = comment_new;
+ }
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubService.java
index 1cbf791..dfb25d9 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubService.java
@@ -56,6 +56,7 @@ public class GitHubService {
private static final String REOPEN = "reopen/";
private final static String CLOSE = "close/";
private final static String EDIT = "edit/"; // Implemented
+ private final static String COMMENT = "comment/";
// private final static String VIEW = "view/";
private final static String SHOW = "show/"; // :user/:repo/:number
private final static String LIST = "list/"; // Implemented
@@ -440,7 +441,6 @@ public class GitHubService {
}
}
-
public GitHubIssue showIssue(final String user, final String repo,final String issueNumber) throws GitHubServiceException {
GetMethod method = null;
try {
@@ -577,4 +577,38 @@ public class GitHubService {
}
}
}
+
+ /**
+ * Add comment on issues.
+ *
+ * @param user
+ * - The user the repository is owned by
+ * @param repo
+ * - The git repository where the issue tracker is hosted
+ * @param issue
+ * @param credentials
+ * @throws GitHubServiceException
+ */
+ public void addComment(final String user, final String repo,
+ final GitHubIssue issue,final GitHubCredentials credentials)
+ throws GitHubServiceException {
+ PostMethod method = null;
+ try {
+ method = new PostMethod(gitURLBase + gitIssueRoot + COMMENT + user
+ + "/" + repo + "/" + issue.getNumber());
+ final NameValuePair comment = new NameValuePair("comment", issue
+ .getComment_new());
+ method.setRequestBody(new NameValuePair[] { comment });
+ setCredentials(credentials);
+ executeMethod(method);
+ }catch (final RuntimeException runTimeException) {
+ throw runTimeException;
+ } catch (final Exception e) {
+ throw new GitHubServiceException(e);
+ } finally {
+ if (method != null) {
+ method.releaseConnection();
+ }
+ }
+ }
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
index 2c847dc..128ea43 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
@@ -25,7 +25,8 @@ public enum GitHubTaskAttributes {
CLOSED_DATE("Closed:",TaskAttribute.DATE_COMPLETION,TaskAttribute.TYPE_DATETIME,false,true,false),
STATUS("Status:",TaskAttribute.STATUS,TaskAttribute.TYPE_SHORT_TEXT,true,false,true),
- REPORTER("Reporter:", TaskAttribute.USER_REPORTER, TaskAttribute.TYPE_PERSON, true, true, false)
+ REPORTER("Reporter:", TaskAttribute.USER_REPORTER, TaskAttribute.TYPE_PERSON, true, true, false),
+ COMMENT_NEW("Comment:", TaskAttribute.COMMENT_NEW, TaskAttribute.TYPE_LONG_RICH_TEXT, false, false, false)
;
private final String id;
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 fd5c2bd..2bb8b00 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
@@ -74,6 +74,7 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
createAttribute(data, GitHubTaskAttributes.MODIFICATION_DATE, toLocalDate(issue.getCreated_at()));
createAttribute(data, GitHubTaskAttributes.CLOSED_DATE, toLocalDate(issue.getClosed_at()));
createAttribute(data, GitHubTaskAttributes.REPORTER, issue.getUser());
+ createAttribute(data, GitHubTaskAttributes.COMMENT_NEW, "");
if (isPartial(data)) {
data.setPartial(true);
@@ -175,6 +176,7 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
issue.setCreated_at(toGitHubDate(taskData,GitHubTaskAttributes.CREATION_DATE));
issue.setCreated_at(toGitHubDate(taskData,GitHubTaskAttributes.MODIFICATION_DATE));
issue.setCreated_at(toGitHubDate(taskData,GitHubTaskAttributes.CLOSED_DATE));
+ issue.setComment_new(getAttributeValue(taskData, GitHubTaskAttributes.COMMENT_NEW));
return issue;
}
@@ -229,11 +231,16 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
if (taskData.isNew()) {
issue = service.openIssue(user , repo, issue, credentials);
} else {
+
+ // handle new comment
+ if(issue.getComment_new() != null) {
+ if(!"".equals(issue.getComment_new())) {
+ service.addComment(user, repo, issue, credentials);
+ }
+ }
+
TaskAttribute operationAttribute = taskData.getRoot().getAttribute(TaskAttribute.OPERATION);
-
GitHubTaskOperation operation = null;
-
-
if (operationAttribute != null) {
String opId = operationAttribute.getValue();
operation = GitHubTaskOperation.fromId(opId);
@@ -254,12 +261,13 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
} else {
service.editIssue(user , repo, issue, credentials);
}
+
}
return new RepositoryResponse(taskData.isNew()?ResponseKind.TASK_CREATED:ResponseKind.TASK_UPDATED,issue.getNumber());
} catch (GitHubServiceException e) {
throw new CoreException(GitHub.createErrorStatus(e));
}
-
+
}