Commit e598ec88 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'mr-with-statuses'

5d74b2ba Use enum_serialize! for as_str method and derives more traits.
c8361223 Use additional parameter instead of three methods.
c3e90190

 Add {opened, merged ,closed}_merge_requests
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !51
parents 100bc63c 5d74b2ba
......@@ -11,7 +11,8 @@ use self::ease::Error as EaseError;
use self::ease::{Request, Response, Url};
extern crate serde;
use self::serde::Deserialize;
use self::serde::{Deserialize, Deserializer, Serialize, Serializer};
use self::serde::de::Error as SerdeError;
extern crate serde_json;
......@@ -57,6 +58,23 @@ pub struct CommitStatusInfo<'a> {
pub description: Option<&'a str>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Optional information for merge requests.
pub enum MergeRequestStateFilter {
/// Get the opened/reopened merge requests.
Opened,
/// Get the closes merge requests.
Closed,
/// Get the merged merge requests.
Merged,
}
enum_serialize!(MergeRequestStateFilter -> "state",
Opened => "opened",
Closed => "closed",
Merged => "merged",
);
impl Gitlab {
/// Create a new Gitlab API representation.
///
......@@ -358,6 +376,15 @@ impl Gitlab {
self._get_paged(&format!("projects/{}/merge_requests", project))
}
/// Get the merge requests with a given state.
pub fn merge_requests_with_state(&self, project: ProjectId, state: MergeRequestStateFilter) -> GitlabResult<Vec<MergeRequest>> {
let mut req = try!(self._mkrequest(&format!("projects/{}/merge_requests", project)));
req.param("state", state.as_str());
Self::_get_paged_req(req)
}
/// Get merge requests.
pub fn merge_request(&self, project: ProjectId, merge_request: MergeRequestId)
-> GitlabResult<MergeRequest> {
......
......@@ -20,10 +20,10 @@ extern crate log;
extern crate quick_error;
mod error;
mod gitlab;
#[macro_use]
mod macros;
mod gitlab;
pub mod systemhooks;
pub mod types;
pub mod webhooks;
......@@ -31,6 +31,7 @@ pub mod hooks;
pub use error::Error;
pub use gitlab::CommitStatusInfo;
pub use gitlab::MergeRequestStateFilter;
pub use gitlab::Gitlab;
pub use gitlab::GitlabResult;
pub use types::*;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment