aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2017-11-17 01:14:22 +0100
committerTeddy Wing2017-11-17 01:14:22 +0100
commit5d18b165bca8dea2b0f09b61df2069a4336a4ff2 (patch)
treea2335f1778d8d99e82c233dcdbbeea21167e948d /src/main.rs
parent7a4b816b6dc8c826db49bc5997709b8e7d1f6933 (diff)
parent399e04a697e42c9a684f14349f6d94208e719832 (diff)
downloadkipper-5d18b165bca8dea2b0f09b61df2069a4336a4ff2.tar.bz2
Merge branch 'only-update-status-when-pull-request-is-opened-or-new-commits-are-pushed'
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 9ac9570..12d71eb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,6 +16,7 @@
// along with Kipper. If not, see <http://www.gnu.org/licenses/>.
extern crate getopts;
+extern crate json;
#[macro_use]
extern crate log;
extern crate stderrlog;
@@ -32,7 +33,7 @@ use std::time::Duration;
use getopts::Options;
use kipper::jenkins;
-use kipper::pull_request::CommitRef;
+use kipper::pull_request::{CommitRef, pull_request_opened_or_synchronized};
const DEFAULT_PORT: u16 = 8000;
@@ -129,7 +130,21 @@ fn main() {
let mut body = String::new();
try_or_400!(data.read_to_string(&mut body));
- let commit_ref = match CommitRef::new(body.as_ref()) {
+ let json = match json::parse(body.as_ref()) {
+ Ok(j) => j,
+ Err(e) => {
+ error!("{}", e.to_string());
+
+ return internal_server_error()
+ },
+ };
+
+ if !pull_request_opened_or_synchronized(json.clone()) {
+ return rouille::Response::text("No status update needed.")
+ .with_status_code(200)
+ }
+
+ let commit_ref = match CommitRef::new(json) {
Ok(cr) => cr,
Err(e) => {
error!("{}", e.to_string());