Skip to content

Commit

Permalink
Merge pull request #87 from arvidj/arvid@merge-requests-fixes
Browse files Browse the repository at this point in the history
Small fixes to merge request bindings
  • Loading branch information
tmcgilchrist committed Aug 28, 2023
2 parents d358087 + 5fd75f7 commit 1ba93d9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

## Added

* `Project.merge_requests`: add parameter `wip`
* `Project.merge_requests`: add parameter `target_branch`
* `Project.merge_requests`: add parameter `per_page`
* `Gitlab` module now exposes `Message` exception

## Bug fixes

* `gitlab.atd`: add `scheduler_failure` to `failure_reason`
* `gitlab.atd`: add `data_integrity_failure` to `failure_reason`
* `gitlab.atd`: make `merge_request.approvals_before_merge` integral
* `gitlab.atd`: make `merge_request.sha` nullable
* `gitlab.atd`: add failure reasons: `api_failure`,
`missing_dependency_failure`, `runner_unsupported`,
`stale_schedule`, `archived_failure`, `unmet_prerequisites`,
Expand Down
4 changes: 2 additions & 2 deletions lib/gitlab.atd
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ type merge_request = {
downvotes: int;
author: user_short;
assignee: user_short nullable;
approvals_before_merge: string nullable;
approvals_before_merge: int nullable;
?allow_collaboration: bool nullable;
?allow_maintainer_to_push: bool nullable;
blocking_discussions_resolved: bool;
Expand All @@ -384,7 +384,7 @@ type merge_request = {
milestone: milestone nullable;
merge_when_pipeline_succeeds: bool;
merge_status: merge_status;
sha: string;
sha: string nullable;
merge_commit_sha: string nullable;
squash_commit_sha: string nullable;
user_notes_count: int;
Expand Down
17 changes: 16 additions & 1 deletion lib/gitlab_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1309,11 +1309,24 @@ struct
| None -> uri
| Some sort -> Uri.add_query_param' uri ("sort", show sort)

let wip_param wip uri =
match wip with
| None -> uri
| Some wip ->
let wip = if wip then "yes" else "no" in
Uri.add_query_param' uri ("wip", wip)

let event_scope_param scope uri =
match scope with
| None -> uri
| Some scope -> Uri.add_query_param' uri ("scope", scope)

let target_branch_param target_branch uri =
match target_branch with
| None -> uri
| Some target_branch ->
Uri.add_query_param' uri ("target_branch", target_branch)

module Event = struct
open Lwt

Expand Down Expand Up @@ -1487,7 +1500,7 @@ struct

let merge_requests ?token ?state ?milestone ?labels ?author ?author_username
?my_reaction ?scope ?created_after ?created_before ?updated_after
?updated_before ?sort ?order_by ~id () =
?updated_before ?sort ?order_by ?target_branch ?wip ?per_page ~id () =
let order_by_param order uri =
let show = function
| `Created_at -> "created_at"
Expand All @@ -1510,6 +1523,8 @@ struct
|> updated_after_param updated_after
|> updated_before_param updated_before
|> order_by_param order_by |> sort_param sort
|> target_branch_param target_branch
|> wip_param wip |> per_page_param per_page
in
API.get_stream ?token ~uri (fun body ->
return (Gitlab_j.merge_requests_of_string body))
Expand Down
3 changes: 3 additions & 0 deletions lib/gitlab_s.mli
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ module type Gitlab = sig
?updated_before:string ->
?sort:Gitlab_t.sort ->
?order_by:[ `Created_at | `Title | `Updated_at ] ->
?target_branch:string ->
?wip:bool ->
?per_page:int ->
id:int ->
unit ->
Gitlab_t.merge_request Stream.t
Expand Down

0 comments on commit 1ba93d9

Please sign in to comment.