summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-29 13:19:31 (EDT)
committer Kevin Sawicki2011-04-29 13:19:31 (EDT)
commit0643f069a0a91db136a01b3e1c2826c3edfd5a2d (patch)
treec9b69c42c18e5fda70ec05697272ef52a6389e48
parentc1f48ed5b7824fded23ade1431fd5bd9399e450e (diff)
downloadegit-github-0643f069a0a91db136a01b3e1c2826c3edfd5a2d.zip
egit-github-0643f069a0a91db136a01b3e1c2826c3edfd5a2d.tar.gz
egit-github-0643f069a0a91db136a01b3e1c2826c3edfd5a2d.tar.bz2
Add support for Gist updated at field.refs/changes/00/3300/1
This date field is now present in the JSON API response and can be used in the GistConnector to compute if a Gist has changed. Change-Id: Iae28cd8cb315a481f9ae845500e3bb766aec119e Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java9
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttribute.java7
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistConnector.java17
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java3
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/Messages.java3
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/messages.properties1
6 files changed, 39 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
index e84e7a4..2707be5 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/Gist.java
@@ -25,6 +25,8 @@ public class Gist {
private boolean isPublic;
private Date createdAt;
+
+ private Date updatedAt;
private int comments;
@@ -153,6 +155,13 @@ public class Gist {
}
/**
+ * @return updatedAt
+ */
+ public Date getUpdatedAt() {
+ return this.updatedAt;
+ }
+
+ /**
* @return url
*/
public String getUrl() {
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttribute.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttribute.java
index ef8608d..75c7d5c 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttribute.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistAttribute.java
@@ -45,6 +45,13 @@ public enum GistAttribute {
TaskAttribute.TYPE_DATETIME, true),
/**
+ * Gist updated date
+ */
+ UPDATED(TaskAttribute.DATE_MODIFICATION,
+ Messages.GistAttribute_LabelModified, TaskAttribute.TYPE_DATETIME,
+ true),
+
+ /**
* Comment being added to gist
*/
COMMENT_NEW(TaskAttribute.COMMENT_NEW,
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 93e10fd..fa7b74a 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
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.internal.github.core.gist;
import java.io.IOException;
+import java.util.Date;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,6 +29,7 @@ import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
@@ -163,7 +165,20 @@ public class GistConnector extends AbstractRepositoryConnector {
*/
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task,
TaskData taskData) {
- return false;
+ TaskAttribute modAttribute = taskData.getRoot().getAttribute(
+ TaskAttribute.DATE_MODIFICATION);
+ if (modAttribute == null)
+ return false;
+
+ boolean changed = true;
+ Date modDate = task.getModificationDate();
+ if (modDate != null) {
+ Date updateDate = taskData.getAttributeMapper().getDateValue(
+ modAttribute);
+ if (updateDate != null)
+ changed = updateDate.after(modDate);
+ }
+ return changed;
}
/**
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
index 420e7d9..b1d7cd1 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java
@@ -117,6 +117,9 @@ public class GistTaskDataHandler extends AbstractTaskDataHandler {
TaskAttribute created = GistAttribute.CREATED.create(data);
mapper.setDateValue(created, gist.getCreatedAt());
+ TaskAttribute updated = GistAttribute.UPDATED.create(data);
+ mapper.setDateValue(updated, gist.getUpdatedAt());
+
TaskAttribute url = GistAttribute.URL.create(data);
url.setValue(gist.getHtmlUrl());
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/Messages.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/Messages.java
index ce3fc9b..50c4e3d 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/Messages.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/Messages.java
@@ -41,6 +41,9 @@ public class Messages extends NLS {
public static String GistAttribute_LabelKey;
/** */
+ public static String GistAttribute_LabelModified;
+
+ /** */
public static String GistAttribute_LabelNewComment;
/** */
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/messages.properties b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/messages.properties
index 8410c1c..aa9f10a 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/messages.properties
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/messages.properties
@@ -5,6 +5,7 @@ GistAttribute_LabelCreated=Created:
GistAttribute_LabelDescription=Description:
GistAttribute_LabelFileUrl=File url
GistAttribute_LabelKey=Key
+GistAttribute_LabelModified=Modified:
GistAttribute_LabelNewComment=New Comment
GistAttribute_LabelSummary=Summary
GistAttribute_LabelUrl=Url