Commit 3ea004c7 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

types: use a string for the MR change count

This is normally an integer, but if the count exceeds a certain number
of files, it comes back with "100+" or the like which is not an integer.
parent 585fd94a
...@@ -291,7 +291,7 @@ fn test_read_merge_request() { ...@@ -291,7 +291,7 @@ fn test_read_merge_request() {
assert_eq!(merge_request.time_stats.total_time_spent, 0); assert_eq!(merge_request.time_stats.total_time_spent, 0);
assert_eq!(merge_request.time_stats.human_time_estimate, None); assert_eq!(merge_request.time_stats.human_time_estimate, None);
assert_eq!(merge_request.time_stats.human_total_time_spent, None); assert_eq!(merge_request.time_stats.human_total_time_spent, None);
assert_eq!(merge_request.changes_count, 3); assert_eq!(merge_request.changes_count, "3");
assert_eq!(merge_request.user_notes_count, 3); assert_eq!(merge_request.user_notes_count, 3);
assert_eq!(merge_request.discussion_locked, None); assert_eq!(merge_request.discussion_locked, None);
assert_eq!(merge_request.should_remove_source_branch, None); assert_eq!(merge_request.should_remove_source_branch, None);
......
...@@ -29,21 +29,6 @@ use std::fmt::{self, Display, Formatter}; ...@@ -29,21 +29,6 @@ use std::fmt::{self, Display, Formatter};
// pub name: String, // pub name: String,
//} //}
fn serialize_u64_string<S>(x: &u64, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,
{
x.to_string().serialize(serializer)
}
fn deserialize_u64_string<'de, D>(deserializer: D) -> Result<u64, D::Error>
where D: Deserializer<'de>,
{
let val = <String as Deserialize>::deserialize(deserializer)?;
val.parse().map_err(|err| {
D::Error::custom(format!("string does not parse as unsigned integer: {:?}", err))
})
}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))] #[cfg_attr(feature="strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
/// Type-safe user ID. /// Type-safe user ID.
...@@ -1398,9 +1383,10 @@ pub struct MergeRequest { ...@@ -1398,9 +1383,10 @@ pub struct MergeRequest {
/// Time estimates. /// Time estimates.
pub time_stats: IssuableTimeStats, pub time_stats: IssuableTimeStats,
/// The number of paths changed by the merge request. /// The number of paths changed by the merge request.
#[serde(serialize_with = "serialize_u64_string")] ///
#[serde(deserialize_with = "deserialize_u64_string")] /// This is an integer suffixed by `+` if there are more files changed than some threshold
pub changes_count: u64, /// (probably determined by a timeout).
pub changes_count: String,
/// The number of comments on the merge request. /// The number of comments on the merge request.
pub user_notes_count: u64, pub user_notes_count: u64,
/// Whether the discussion has been locked. /// Whether the discussion has been locked.
...@@ -1473,9 +1459,7 @@ pub struct MergeRequestChanges { ...@@ -1473,9 +1459,7 @@ pub struct MergeRequestChanges {
/// Time estimates. /// Time estimates.
pub time_stats: IssuableTimeStats, pub time_stats: IssuableTimeStats,
/// The number of paths changed by the merge request. /// The number of paths changed by the merge request.
#[serde(serialize_with = "serialize_u64_string")] pub changes_count: String,
#[serde(deserialize_with = "deserialize_u64_string")]
pub changes_count: u64,
/// The number of comments on the merge request. /// The number of comments on the merge request.
pub user_notes_count: u64, pub user_notes_count: u64,
/// Whether the discussion has been locked. /// Whether the discussion has been locked.
......
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