Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jocelyn Falempe
rust-gitlab
Commits
2ea38649
Commit
2ea38649
authored
Mar 03, 2020
by
Jocelyn Falempe
Browse files
Add a simple function to create a merge request using gitlab API.
using derive builder to handle optional parameters
parent
53e90ad0
Pipeline
#163627
passed with stages
in 6 minutes and 19 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/gitlab.rs
View file @
2ea38649
...
...
@@ -1476,6 +1476,15 @@ impl Gitlab {
)
}
/// Create a new merge request
pub
fn
create_merge_request
(
&
self
,
project
:
ProjectId
,
params
:
CreateMergeRequestParams
,
)
->
GitlabResult
<
MergeRequest
>
{
self
.post_with_param
(
format!
(
"projects/{}/merge_requests"
,
project
),
&
params
)
}
/// Get all pipelines for a project.
pub
fn
pipelines
<
I
,
K
,
V
>
(
&
self
,
...
...
src/types.rs
View file @
2ea38649
...
...
@@ -1934,6 +1934,45 @@ impl From<MergeRequestChanges> for MergeRequest {
}
}
/// param to create a merge request.
#[derive(Serialize,
Deserialize,
Builder,
Debug,
Clone,
Default)]
#[builder(default)]
#[builder(field(private))]
#[builder(setter(into,
strip_option))]
pub
struct
CreateMergeRequestParams
{
/// The source branch on source project
pub
source_branch
:
String
,
/// The target branch
pub
target_branch
:
String
,
/// Title of MR
pub
title
:
String
,
/// assignee user ID
pub
assignee_id
:
Option
<
UserId
>
,
/// The ID of the user(s) to assign the MR to.
/// Set to 0 or provide an empty value to unassign all assignees.
pub
assignee_ids
:
Option
<
Vec
<
UserId
>>
,
/// Description of MR
pub
description
:
Option
<
String
>
,
/// The target project (numeric id) if different from source project
pub
target_project_id
:
Option
<
ProjectId
>
,
/// Labels for MR as a comma-separated list
pub
labels
:
Option
<
String
>
,
/// The global ID of a milestone
pub
milestone_id
:
Option
<
MilestoneId
>
,
/// Flag indicating if a merge request should remove the source branch when merging
pub
remove_source_branch
:
Option
<
bool
>
,
/// Allow commits from members who can merge to the target branch
pub
allow_collaboration
:
Option
<
bool
>
,
/// Squash commits into a single commit when merging
pub
squash
:
Option
<
bool
>
,
}
impl
CreateMergeRequestParams
{
pub
fn
builder
()
->
CreateMergeRequestParamsBuilder
{
CreateMergeRequestParamsBuilder
::
default
()
}
}
/// Type-safe SSH key ID.
#[derive(Serialize,
Deserialize,
Debug,
Clone,
Copy,
Hash,
PartialEq,
Eq)]
pub
struct
SshKeyId
(
u64
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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