Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nicholas Bailey
rust-gitlab
Commits
3140f21f
Commit
3140f21f
authored
May 27, 2020
by
Ben Boeckel
⛰
Browse files
api/projects: fix issue milestone filtering API
parent
59b9eade
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
3140f21f
# v0.1300.0 (unreleased)
## Changes
*
The
`api::projects::issues::Issues`
endpoint's
`milestone`
field was
changed to match the actual API exposed by GitLab (with
`None`
and
`Any`
options).
# v0.1210.2
## New request body handling
...
...
src/api/projects/issues/issues.rs
View file @
3140f21f
...
...
@@ -61,6 +61,29 @@ impl<'a, 'b: 'a> ParamValue<'static> for &'b Labels<'a> {
}
}
#[derive(Debug,
Clone)]
enum
Milestone
<
'a
>
{
None
,
Any
,
Named
(
Cow
<
'a
,
str
>
),
}
impl
<
'a
>
Milestone
<
'a
>
{
fn
as_str
(
&
self
)
->
&
str
{
match
self
{
Milestone
::
None
=>
"None"
,
Milestone
::
Any
=>
"Any"
,
Milestone
::
Named
(
name
)
=>
name
.as_ref
(),
}
}
}
impl
<
'a
,
'b
:
'a
>
ParamValue
<
'a
>
for
&
'b
Milestone
<
'a
>
{
fn
as_value
(
self
)
->
Cow
<
'a
,
str
>
{
self
.as_str
()
.into
()
}
}
/// Filter issues by a scope.
#[derive(Debug,
Clone,
Copy,
PartialEq,
Eq)]
pub
enum
IssueScope
{
...
...
@@ -240,9 +263,9 @@ pub struct Issues<'a> {
/// Include label details in the result.
#[builder(default)]
with_labels_details
:
Option
<
bool
>
,
/// Filter issues with a milestone
title
.
#[builder(setter(
into
),
default)]
milestone
:
Option
<
Cow
<
'a
,
str
>>
,
/// Filter issues with a milestone.
#[builder(setter(
name
=
"_milestone"
),
default
,
private
)]
milestone
:
Option
<
Milestone
<
'a
>>
,
/// Filter issues within a scope.
#[builder(default)]
scope
:
Option
<
IssueScope
>
,
...
...
@@ -358,6 +381,27 @@ impl<'a> IssuesBuilder<'a> {
self
}
/// Filter issues without a milestone.
pub
fn
without_milestone
(
&
mut
self
)
->
&
mut
Self
{
self
.milestone
=
Some
(
Some
(
Milestone
::
None
));
self
}
/// Filter issues with any milestone.
pub
fn
any_milestone
(
&
mut
self
)
->
&
mut
Self
{
self
.milestone
=
Some
(
Some
(
Milestone
::
Any
));
self
}
/// Filter issues with a given milestone.
pub
fn
milestone
<
M
>
(
&
mut
self
,
milestone
:
M
)
->
&
mut
Self
where
M
:
Into
<
Cow
<
'a
,
str
>>
,
{
self
.milestone
=
Some
(
Some
(
Milestone
::
Named
(
milestone
.into
())));
self
}
/// Filter unassigned issues.
pub
fn
unassigned
(
&
mut
self
)
->
&
mut
Self
{
self
.assignee
=
Some
(
Some
(
Assignee
::
Unassigned
));
...
...
@@ -489,7 +533,7 @@ mod tests {
use
crate
::
api
::
projects
::
issues
::{
IssueOrderBy
,
IssueScope
,
IssueState
,
IssueWeight
,
Issues
};
use
super
::{
Labels
,
ReactionEmoji
};
use
super
::{
Labels
,
Milestone
,
ReactionEmoji
};
#[test]
fn
issue_state_as_str
()
{
...
...
@@ -529,6 +573,19 @@ mod tests {
}
}
#[test]
fn
issue_milestone_as_str
()
{
let
items
=
&
[
(
Milestone
::
Any
,
"Any"
),
(
Milestone
::
None
,
"None"
),
(
Milestone
::
Named
(
"milestone"
.into
()),
"milestone"
),
];
for
(
i
,
s
)
in
items
{
assert_eq!
(
i
.as_str
(),
*
s
);
}
}
#[test]
fn
issue_scope_as_str
()
{
let
items
=
&
[
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment