Commit adece3e7 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

rustfmt: apply suggestions

parent e7162e07
......@@ -3,6 +3,7 @@ fn_args_density = "Compressed"
fn_args_layout = "Visual"
match_block_trailing_comma = true
match_wildcard_trailing_comma = true
reorder_imported_names = true
struct_lit_multiline_style = "ForceMulti"
struct_lit_trailing_comma = "Always"
struct_trailing_comma = "Always"
......
......@@ -14,7 +14,6 @@ extern crate serde;
use self::serde::Deserialize;
extern crate serde_json;
use self::serde_json::from_value;
extern crate url;
use self::url::percent_encoding::{PATH_SEGMENT_ENCODE_SET, percent_encode};
......@@ -158,15 +157,18 @@ impl Gitlab {
request
.param("build_events", Self::bool_param_value(events.build()))
.param("issues_events", Self::bool_param_value(events.issues()))
.param("merge_requests_events", Self::bool_param_value(events.merge_requests()))
.param("merge_requests_events",
Self::bool_param_value(events.merge_requests()))
.param("note_events", Self::bool_param_value(events.note()))
.param("pipeline_events", Self::bool_param_value(events.pipeline()))
.param("push_events", Self::bool_param_value(events.push()))
.param("wiki_page_events", Self::bool_param_value(events.wiki_page()));
.param("wiki_page_events",
Self::bool_param_value(events.wiki_page()));
}
/// Add a project hook.
pub fn add_hook(&self, project: ProjectId, url: &str, events: WebhookEvents) -> GitlabResult<Hook> {
pub fn add_hook(&self, project: ProjectId, url: &str, events: WebhookEvents)
-> GitlabResult<Hook> {
let mut req = try!(self._mkrequest(&format!("projects/{}/hooks", project)));
Self::set_event_flags(&mut req, events);
......@@ -229,7 +231,9 @@ impl Gitlab {
/// Get comments on a commit.
pub fn commit_comments(&self, project: ProjectId, commit: &str)
-> GitlabResult<Vec<CommitNote>> {
self._get_paged(&format!("projects/{}/repository/commits/{}/comments", project, commit))
self._get_paged(&format!("projects/{}/repository/commits/{}/comments",
project,
commit))
}
/// Get comments on a commit.
......@@ -266,7 +270,9 @@ impl Gitlab {
/// Get the statuses of a commit.
pub fn commit_statuses(&self, project: ProjectId, commit: &str)
-> GitlabResult<Vec<CommitStatus>> {
self._get_paged(&format!("projects/{}/repository/commits/{}/statuses", project, commit))
self._get_paged(&format!("projects/{}/repository/commits/{}/statuses",
project,
commit))
}
/// Get the statuses of a commit.
......@@ -354,9 +360,12 @@ impl Gitlab {
/// Award a merge request note with an award.
pub fn award_merge_request_note(&self, project: ProjectId, merge_request: MergeRequestId,
note: NoteId, award: &str) -> GitlabResult<AwardEmoji> {
note: NoteId, award: &str)
-> GitlabResult<AwardEmoji> {
let path = &format!("projects/{}/merge_requests/{}/notes/{}/award_emoji",
project, merge_request, note);
project,
merge_request,
note);
let mut req = try!(self._mkrequest(path));
req.param("name", award);
......@@ -366,7 +375,8 @@ impl Gitlab {
/// Get the awards for a merge request note.
pub fn merge_request_note_awards(&self, project: ProjectId, merge_request: MergeRequestId,
note: NoteId) -> GitlabResult<Vec<AwardEmoji>> {
note: NoteId)
-> GitlabResult<Vec<AwardEmoji>> {
self._get_paged(&format!("projects/{}/merge_requests/{}/notes/{}/award_emoji",
project,
merge_request,
......@@ -418,7 +428,7 @@ impl Gitlab {
Ok(rsp) => {
let v = try!(rsp.from_json().map_err(Error::Ease));
Ok(try!(from_value::<T>(v)))
Ok(try!(serde_json::from_value::<T>(v)))
},
Err(err) => {
if let EaseError::UnsuccessfulResponse(rsp) = err {
......
......@@ -11,7 +11,7 @@ use self::serde::{Deserialize, Deserializer};
use self::serde::de::Error;
extern crate serde_json;
use self::serde_json::{from_value, Value};
use self::serde_json::Value;
use super::systemhooks::SystemHook;
use super::webhooks::WebHook;
......@@ -29,12 +29,12 @@ impl Deserialize for GitlabHook {
// Look for `object_kind` first because some web hooks also have `event_name` which would
// cause a false match here.
let hook_res = if val.pointer("/object_kind").is_some() {
from_value(val).map(GitlabHook::Web)
} else if val.pointer("/event_name").is_some() {
from_value(val).map(GitlabHook::System)
} else {
return Err(D::Error::missing_field("either object_kind or event_name"));
};
serde_json::from_value(val).map(GitlabHook::Web)
} else if val.pointer("/event_name").is_some() {
serde_json::from_value(val).map(GitlabHook::System)
} else {
return Err(D::Error::missing_field("either object_kind or event_name"));
};
hook_res.map_err(|err| D::Error::invalid_value(&format!("{:?}", err)))
}
......
......@@ -14,7 +14,7 @@ use self::serde::{Deserialize, Deserializer, Serialize, Serializer};
use self::serde::de::{Error, Type};
extern crate serde_json;
use self::serde_json::{from_value, Value};
use self::serde_json::Value;
use super::types::{AccessLevel, GroupId, ObjectId, ProjectId, SshKeyId, UserId};
use super::webhooks::{CommitHookAttrs, ProjectHookAttrs};
......@@ -260,7 +260,7 @@ impl Deserialize for SystemHook {
Some(&Value::String(ref name)) => name,
Some(_) => {
return Err(D::Error::invalid_type(Type::String));
}
},
None => {
return Err(D::Error::missing_field("event_name"));
},
......@@ -268,30 +268,30 @@ impl Deserialize for SystemHook {
.to_string();
let hook_res = match event_name.as_str() {
"project_create" |
"project_destroy" |
"project_rename" |
"project_transfer" => from_value(val).map(SystemHook::Project),
"project_create" |
"project_destroy" |
"project_rename" |
"project_transfer" => serde_json::from_value(val).map(SystemHook::Project),
"user_add_to_team" |
"user_remove_from_team" => from_value(val).map(SystemHook::ProjectMember),
"user_add_to_team" |
"user_remove_from_team" => serde_json::from_value(val).map(SystemHook::ProjectMember),
"user_create" | "user_destroy" => from_value(val).map(SystemHook::User),
"user_create" | "user_destroy" => serde_json::from_value(val).map(SystemHook::User),
"key_create" | "key_destroy" => from_value(val).map(SystemHook::Key),
"key_create" | "key_destroy" => serde_json::from_value(val).map(SystemHook::Key),
"group_create" | "group_destroy" => from_value(val).map(SystemHook::Group),
"group_create" | "group_destroy" => serde_json::from_value(val).map(SystemHook::Group),
"user_add_to_group" |
"user_remove_from_group" => from_value(val).map(SystemHook::GroupMember),
"user_add_to_group" |
"user_remove_from_group" => serde_json::from_value(val).map(SystemHook::GroupMember),
"push" | "tag_push" => from_value(val).map(SystemHook::Push),
"push" | "tag_push" => serde_json::from_value(val).map(SystemHook::Push),
_ => {
return Err(D::Error::invalid_value(&format!("unrecognized system event name: {}",
event_name)));
},
};
_ => {
return Err(D::Error::invalid_value(&format!("unrecognized system event name: {}",
event_name)));
},
};
hook_res.map_err(|err| D::Error::invalid_value(&format!("{:?}", err)))
}
......
......@@ -14,7 +14,7 @@ use self::serde::{Deserialize, Deserializer, Serialize, Serializer};
use self::serde::de::Error;
extern crate serde_json;
use self::serde_json::{from_value, Value};
use self::serde_json::Value;
use std::fmt::{self, Display, Formatter};
......@@ -919,9 +919,9 @@ impl Deserialize for IssueReference {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
let val = try!(Value::deserialize(deserializer));
from_value::<Issue>(val.clone())
serde_json::from_value::<Issue>(val.clone())
.map(IssueReference::Internal)
.or_else(|_| from_value::<ExternalIssue>(val).map(IssueReference::External))
.or_else(|_| serde_json::from_value::<ExternalIssue>(val).map(IssueReference::External))
.map_err(|err| D::Error::invalid_value(&format!("{:?}", err)))
}
}
......@@ -1187,7 +1187,9 @@ impl AwardEmoji {
pub fn awardable_id(&self) -> AwardableId {
match self.awardable_type {
AwardableType::Issue => AwardableId::Issue(IssueId::new(self.awardable_id)),
AwardableType::MergeRequest => AwardableId::MergeRequest(MergeRequestId::new(self.awardable_id)),
AwardableType::MergeRequest => {
AwardableId::MergeRequest(MergeRequestId::new(self.awardable_id))
},
AwardableType::Snippet => AwardableId::Snippet(SnippetId::new(self.awardable_id)),
AwardableType::Note => AwardableId::Note(NoteId::new(self.awardable_id)),
}
......
......@@ -14,10 +14,10 @@ use self::serde::{Deserialize, Deserializer, Serialize, Serializer};
use self::serde::de::{Error, Type};
extern crate serde_json;
use self::serde_json::{from_value, Value};
use self::serde_json::Value;
use super::types::{BuildId, IssueId, IssueState, MergeRequestId, MergeRequestState, MergeStatus,
MilestoneId, NoteableId, NoteId, NoteType, ObjectId, ProjectId, SnippetId,
MilestoneId, NoteId, NoteType, NoteableId, ObjectId, ProjectId, SnippetId,
UserId};
#[derive(Debug)]
......@@ -511,21 +511,21 @@ impl Deserialize for WebHook {
.to_string();
let hook_res = match object_kind.as_str() {
"push" | "tag_push" => from_value(val).map(WebHook::Push),
"push" | "tag_push" => serde_json::from_value(val).map(WebHook::Push),
"issue" => from_value(val).map(WebHook::Issue),
"issue" => serde_json::from_value(val).map(WebHook::Issue),
"merge_request" => from_value(val).map(WebHook::MergeRequest),
"merge_request" => serde_json::from_value(val).map(WebHook::MergeRequest),
"note" => from_value(val).map(WebHook::Note),
"note" => serde_json::from_value(val).map(WebHook::Note),
"build" => from_value(val).map(WebHook::Build),
"build" => serde_json::from_value(val).map(WebHook::Build),
_ => {
return Err(D::Error::invalid_value(&format!("unrecognized webhook object kind: {}",
object_kind)));
},
};
_ => {
return Err(D::Error::invalid_value(&format!("unrecognized webhook object kind: {}",
object_kind)));
},
};
hook_res.map_err(|err| D::Error::invalid_value(&format!("{:?}", err)))
}
......
Supports Markdown
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