Commit 1a1ff9ff authored by Jocelyn Falempe's avatar Jocelyn Falempe
Browse files

Add a simple function to create a merge request using gitlab API.

using derive builder to handle optional parameters
parent e6d3c8d0
Pipeline #163374 passed with stages
in 5 minutes and 19 seconds
......@@ -1423,6 +1423,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,
......
......@@ -1933,6 +1933,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
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)
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);
......
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