Commit 4eb8f51d authored by DCjanus's avatar DCjanus
Browse files

work with rustfmt

parent 1fbd3012
......@@ -44,14 +44,14 @@ impl Token {
HeaderValue::from_str(&token).map_err(|_| ErrorKind::HeaderValueParse)?;
token_header_value.set_sensitive(true);
req.header("PRIVATE-TOKEN", token_header_value)
}
},
Token::OAuth2(token) => {
let value = format!("Bearer {}", token);
let mut token_header_value =
HeaderValue::from_str(&value).map_err(|_| ErrorKind::HeaderValueParse)?;
token_header_value.set_sensitive(true);
req.header("Authorization", token_header_value)
}
},
})
}
}
......
......@@ -518,7 +518,10 @@ fn test_read_project() {
assert_eq!(project.namespace.kind, NamespaceKind::Group);
assert_eq!(project.namespace.full_path, "utils");
assert_eq!(project.namespace.avatar_url, None);
assert_eq!(project.namespace.web_url, "https://gitlab.kitware.com/groups/utils");
assert_eq!(
project.namespace.web_url,
"https://gitlab.kitware.com/groups/utils"
);
assert!(project.namespace.members_count_with_descendants.is_none());
assert!(project.forked_from_project.is_none());
assert_eq!(project.avatar_url, None);
......@@ -791,7 +794,7 @@ fn test_read_resoruce_label_events() {
Some(ResourceLabelEventTarget::Issue(id)) if id.value() == 69328 => {
// this is the expected value
},
x => panic!("Unexpected resource_target: {:?}", x)
x => panic!("Unexpected resource_target: {:?}", x),
}
let label = event.label.unwrap();
......
......@@ -2001,22 +2001,26 @@ impl Note {
/// The ID of the entity the note is attached to.
pub fn noteable_id(&self) -> Option<NoteableId> {
match self.noteable_type {
NoteType::Commit => self
.noteable_id
.as_str()
.map(|id| NoteableId::Commit(ObjectId::new(id))),
NoteType::Issue => self
.noteable_id
.as_u64()
.map(|id| NoteableId::Issue(IssueId::new(id))),
NoteType::MergeRequest => self
.noteable_id
.as_u64()
.map(|id| NoteableId::MergeRequest(MergeRequestId::new(id))),
NoteType::Snippet => self
.noteable_id
.as_u64()
.map(|id| NoteableId::Snippet(SnippetId::new(id))),
NoteType::Commit => {
self.noteable_id
.as_str()
.map(|id| NoteableId::Commit(ObjectId::new(id)))
},
NoteType::Issue => {
self.noteable_id
.as_u64()
.map(|id| NoteableId::Issue(IssueId::new(id)))
},
NoteType::MergeRequest => {
self.noteable_id
.as_u64()
.map(|id| NoteableId::MergeRequest(MergeRequestId::new(id)))
},
NoteType::Snippet => {
self.noteable_id
.as_u64()
.map(|id| NoteableId::Snippet(SnippetId::new(id)))
},
}
}
......@@ -2025,16 +2029,18 @@ impl Note {
pub fn noteable_iid(&self) -> Option<NoteableInternalId> {
match self.noteable_type {
NoteType::Commit => None,
NoteType::Issue => self
.noteable_iid
.as_ref()
.and_then(|value| value.as_u64())
.map(|id| NoteableInternalId::Issue(IssueInternalId::new(id))),
NoteType::MergeRequest => self
.noteable_iid
.as_ref()
.and_then(|value| value.as_u64())
.map(|id| NoteableInternalId::MergeRequest(MergeRequestInternalId::new(id))),
NoteType::Issue => {
self.noteable_iid
.as_ref()
.and_then(|value| value.as_u64())
.map(|id| NoteableInternalId::Issue(IssueInternalId::new(id)))
},
NoteType::MergeRequest => {
self.noteable_iid
.as_ref()
.and_then(|value| value.as_u64())
.map(|id| NoteableInternalId::MergeRequest(MergeRequestInternalId::new(id)))
},
NoteType::Snippet => None,
}
}
......@@ -2104,7 +2110,7 @@ impl AwardEmoji {
AwardableType::Issue => AwardableId::Issue(IssueId::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)),
}
......@@ -2279,26 +2285,31 @@ impl Event {
/// The ID of an event's target.
pub fn target_id(&self) -> Option<EventTargetId> {
match self.target_type {
EventTargetType::Commit => self
.target_id
.as_str()
.map(|id| EventTargetId::Commit(ObjectId(id.to_string()))),
EventTargetType::Issue => self
.target_id
.as_u64()
.map(|id| EventTargetId::Issue(IssueId(id))),
EventTargetType::MergeRequest => self
.target_id
.as_u64()
.map(|id| EventTargetId::MergeRequest(MergeRequestId(id))),
EventTargetType::Snippet => self
.target_id
.as_u64()
.map(|id| EventTargetId::Snippet(SnippetId(id))),
EventTargetType::ProjectSnippet => self
.target_id
.as_u64()
.map(|id| EventTargetId::Snippet(SnippetId(id))),
EventTargetType::Commit => {
self.target_id
.as_str()
.map(|id| EventTargetId::Commit(ObjectId(id.to_string())))
},
EventTargetType::Issue => {
self.target_id
.as_u64()
.map(|id| EventTargetId::Issue(IssueId(id)))
},
EventTargetType::MergeRequest => {
self.target_id
.as_u64()
.map(|id| EventTargetId::MergeRequest(MergeRequestId(id)))
},
EventTargetType::Snippet => {
self.target_id
.as_u64()
.map(|id| EventTargetId::Snippet(SnippetId(id)))
},
EventTargetType::ProjectSnippet => {
self.target_id
.as_u64()
.map(|id| EventTargetId::Snippet(SnippetId(id)))
},
}
}
}
......@@ -2482,12 +2493,16 @@ impl ResourceLabelEvent {
/// Returns the id of the merge request or issue that this event is from
pub fn event_target(&self) -> Option<ResourceLabelEventTarget> {
match self.resource_type.as_ref() {
"MergeRequest" => Some(ResourceLabelEventTarget::MergeRequest(MergeRequestId::new(
self.resource_id,
))),
"Issue" => Some(ResourceLabelEventTarget::Issue(IssueId::new(
self.resource_id,
))),
"MergeRequest" => {
Some(ResourceLabelEventTarget::MergeRequest(MergeRequestId::new(
self.resource_id,
)))
},
"Issue" => {
Some(ResourceLabelEventTarget::Issue(IssueId::new(
self.resource_id,
)))
},
_ => None,
}
}
......
......@@ -43,17 +43,16 @@ impl<'de> Deserialize<'de> for HookDate {
let val = String::deserialize(deserializer)?;
Utc.datetime_from_str(&val, "%Y-%m-%d %H:%M:%S UTC")
.or_else(|_| DateTime::parse_from_rfc3339(&val).map(|dt| dt.with_timezone(&Utc)))
.or_else(|_| {
DateTime::parse_from_rfc3339(&val).map(|dt| dt.with_timezone(&Utc))
})
.or_else(|_| {
DateTime::parse_from_str(&val, "%Y-%m-%d %H:%M:%S %z").map(|dt| dt.with_timezone(&Utc))
DateTime::parse_from_str(&val, "%Y-%m-%d %H:%M:%S %z")
.map(|dt| dt.with_timezone(&Utc))
})
.map_err(|err| {
D::Error::invalid_value(
Unexpected::Other("hook date"),
&format!("Unsupported format: {} {:?}", val, err).as_str(),
)
)
})
.map(HookDate)
}
......
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