Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron S. Hawley2019-06-17 02:33:28 -0400
committerAaron S. Hawley2019-06-17 09:17:30 -0400
commit7a8c24d36f2214f6d7a97bb09249974d978188fe (patch)
tree6023cce26826c8adc103f360442276832b68bd27
parent0f7592f24a097ab53c9628d0d4b37b55d0bf1f1e (diff)
downloadegit-github-7a8c24d36f2214f6d7a97bb09249974d978188fe.tar.gz
egit-github-7a8c24d36f2214f6d7a97bb09249974d978188fe.tar.xz
egit-github-7a8c24d36f2214f6d7a97bb09249974d978188fe.zip
Add new fields for GitHub push event
Fields that were missing: * After * Created, Deleted, Forced * Base ref * Compare * Distinct size * Head commit * Organization, Pusher, Repository, Sender https://developer.github.com/v3/activity/events/types/#pushevent Bug: 521783 Change-Id: Ibdc22e983aa81ddb638c2fd8ad724ea8957be43f Signed-off-by: Aaron S. Hawley <aaron.s.hawley@gmail.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java21
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java224
2 files changed, 245 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java
index f4911093..e914b51c 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/PushPayloadTest.java
@@ -13,6 +13,8 @@
package org.eclipse.egit.github.core.tests;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
@@ -36,8 +38,20 @@ public class PushPayloadTest {
assertNull(payload.getHead());
assertNull(payload.getRef());
assertEquals(0, payload.getSize());
+ assertEquals(0, payload.getDistinctSize());
assertNull(payload.getCommits());
assertNull(payload.getBefore());
+ assertNull(payload.getAfter());
+ assertFalse(payload.isCreated());
+ assertFalse(payload.isDeleted());
+ assertFalse(payload.isForced());
+ assertNull(payload.getBaseRef());
+ assertNull(payload.getCompare());
+ assertNull(payload.getHeadCommit());
+ assertNull(payload.getRepository());
+ assertNull(payload.getPusher());
+ assertNull(payload.getOrganization());
+ assertNull(payload.getSender());
}
/**
@@ -51,7 +65,14 @@ public class PushPayloadTest {
assertEquals("head", payload.setHead("head").getHead());
assertEquals("ref", payload.setRef("ref").getRef());
assertEquals(9000, payload.setSize(9000).getSize());
+ assertEquals(8000, payload.setDistinctSize(8000).getDistinctSize());
assertEquals(commits, payload.setCommits(commits).getCommits());
assertEquals("a1b2", payload.setBefore("a1b2").getBefore());
+ assertEquals("2b1a", payload.setAfter("2b1a").getAfter());
+ assertTrue(payload.setCreated(true).isCreated());
+ assertTrue(payload.setDeleted(true).isDeleted());
+ assertTrue(payload.setForced(true).isForced());
+ assertEquals("base", payload.setBaseRef("base").getBaseRef());
+ assertEquals("http", payload.setCompare("http").getCompare());
}
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java
index 1ec47383..1a509904 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/PushPayload.java
@@ -12,9 +12,14 @@
*******************************************************************************/
package org.eclipse.egit.github.core.event;
+import com.google.gson.annotations.SerializedName;
+
import java.util.List;
import org.eclipse.egit.github.core.Commit;
+import org.eclipse.egit.github.core.Organization;
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.User;
/**
* PushEvent payload model class.
@@ -23,16 +28,43 @@ public class PushPayload extends EventPayload {
private static final long serialVersionUID = -1542484898531583478L;
+ private String after;
+
private String before;
+ private boolean created;
+
+ private boolean deleted;
+
+ private boolean forced;
+
private String head;
private String ref;
+ @SerializedName("base_ref")
+ private String baseRef;
+
+ private String compare;
+
private int size;
+ @SerializedName("distinct_size")
+ private int distinctSize;
+
private List<Commit> commits;
+ @SerializedName("head_commit")
+ private Commit headCommit;
+
+ private Repository repository;
+
+ private User pusher;
+
+ private Organization organization;
+
+ private User sender;
+
/**
* @return before
*/
@@ -50,6 +82,70 @@ public class PushPayload extends EventPayload {
}
/**
+ * @return after
+ */
+ public String getAfter() {
+ return after;
+ }
+
+ /**
+ * @param after
+ * @return this payload
+ */
+ public PushPayload setAfter(String after) {
+ this.after = after;
+ return this;
+ }
+
+ /**
+ * @return created
+ */
+ public boolean isCreated() {
+ return created;
+ }
+
+ /**
+ * @param created
+ * @return this PushEvent
+ */
+ public PushPayload setCreated(boolean created) {
+ this.created = created;
+ return this;
+ }
+
+ /**
+ * @return deleted
+ */
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ /**
+ * @param deleted
+ * @return this PushEvent
+ */
+ public PushPayload setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ return this;
+ }
+
+ /**
+ * @return forced
+ */
+ public boolean isForced() {
+ return forced;
+ }
+
+ /**
+ * @param forced
+ * @return this PushEvent
+ */
+ public PushPayload setForced(boolean forced) {
+ this.forced = forced;
+ return this;
+ }
+
+ /**
* @return head
*/
public String getHead() {
@@ -82,6 +178,38 @@ public class PushPayload extends EventPayload {
}
/**
+ * @return baseRef
+ */
+ public String getBaseRef() {
+ return baseRef;
+ }
+
+ /**
+ * @param baseRef
+ * @return this PushEvent
+ */
+ public PushPayload setBaseRef(String baseRef) {
+ this.baseRef = baseRef;
+ return this;
+ }
+
+ /**
+ * @return compare
+ */
+ public String getCompare() {
+ return compare;
+ }
+
+ /**
+ * @param compare
+ * @return this PushEvent
+ */
+ public PushPayload setCompare(String compare) {
+ this.compare = compare;
+ return this;
+ }
+
+ /**
* @return size
*/
public int getSize() {
@@ -98,6 +226,22 @@ public class PushPayload extends EventPayload {
}
/**
+ * @return distinctSize
+ */
+ public int getDistinctSize() {
+ return distinctSize;
+ }
+
+ /**
+ * @param distinctSize
+ * @return this PushEvent
+ */
+ public PushPayload setDistinctSize(int distinctSize) {
+ this.distinctSize = distinctSize;
+ return this;
+ }
+
+ /**
* @return commits
*/
public List<Commit> getCommits() {
@@ -112,4 +256,84 @@ public class PushPayload extends EventPayload {
this.commits = commits;
return this;
}
+
+ /**
+ * @return headCommit
+ */
+ public Commit getHeadCommit() {
+ return headCommit;
+ }
+
+ /**
+ * @param headCommit
+ * @return this PushEvent
+ */
+ public PushPayload setHeadCommit(Commit headCommit) {
+ this.headCommit = headCommit;
+ return this;
+ }
+
+ /**
+ * @return repository
+ */
+ public Repository getRepository() {
+ return repository;
+ }
+
+ /**
+ * @param repository
+ * @return this PushEvent
+ */
+ public PushPayload setRepository(Repository repository) {
+ this.repository = repository;
+ return this;
+ }
+
+ /**
+ * @return pusher
+ */
+ public User getPusher() {
+ return pusher;
+ }
+
+ /**
+ * @param pusher
+ * @return this PushEvent
+ */
+ public PushPayload setPusher(User pusher) {
+ this.pusher = pusher;
+ return this;
+ }
+
+ /**
+ * @return organization
+ */
+ public Organization getOrganization() {
+ return organization;
+ }
+
+ /**
+ * @param organization
+ * @return this PushEvent
+ */
+ public PushPayload setOrganization(Organization organization) {
+ this.organization = organization;
+ return this;
+ }
+
+ /**
+ * @return sender
+ */
+ public User getSender() {
+ return sender;
+ }
+
+ /**
+ * @param sender
+ * @return this PushEvent
+ */
+ public PushPayload setSender(User sender) {
+ this.sender = sender;
+ return this;
+ }
}

Back to the top