diff options
author | Matthias Sohn | 2015-03-04 23:09:15 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-03-05 12:25:42 +0000 |
commit | 0857b455f61a38cd8ec96de9eef6c82c04f8a9a1 (patch) | |
tree | 74371b6740f54933f72d840e96c34f3b5aa04b0a /org.eclipse.egit.github.core | |
parent | eb83c17e47247e19c41aaba497f4c91d6e2a96c5 (diff) | |
download | egit-github-0857b455f61a38cd8ec96de9eef6c82c04f8a9a1.tar.gz egit-github-0857b455f61a38cd8ec96de9eef6c82c04f8a9a1.tar.xz egit-github-0857b455f61a38cd8ec96de9eef6c82c04f8a9a1.zip |
Prevent invalid CommitStatus.state values
see https://developer.github.com/v3/repos/statuses/
Change-Id: I62f8cbf1e276a3d3da270292153a80028c872b2c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r-- | org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStatus.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStatus.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStatus.java index b6df83e4..e178014d 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStatus.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/CommitStatus.java @@ -11,6 +11,7 @@ package org.eclipse.egit.github.core; import java.io.Serializable; +import java.text.MessageFormat; import java.util.Date; import org.eclipse.egit.github.core.util.DateUtils; @@ -150,10 +151,15 @@ public class CommitStatus implements Serializable { /** * @param state * @return this status + * throws {@link IllegalArgumentException} if state is invalid */ public CommitStatus setState(final String state) { - this.state = state; - return this; + if (STATE_ERROR.equals(state) || STATE_FAILURE.equals(state) || STATE_PENDING.equals(state) + || STATE_SUCCESS.equals(state)) { + this.state = state; + return this; + } + throw new IllegalArgumentException(MessageFormat.format("Invalid state {0}", state)); } /** |