1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/merge_request.proto
6
7package ermiteconnect
8
9import (
10 ermite "bnema.dev/ermite-api/gen/ermite"
11 connect "connectrpc.com/connect"
12 context "context"
13 errors "errors"
14 http "net/http"
15 strings "strings"
16)
17
18// This is a compile-time assertion to ensure that this generated file and the connect package are
19// compatible. If you get a compiler error that this constant is not defined, this code was
20// generated with a version of connect newer than the one compiled into your binary. You can fix the
21// problem by either regenerating this code with an older version of connect or updating the connect
22// version compiled into your binary.
23const _ = connect.IsAtLeastVersion1_13_0
24
25const (
26 // MergeRequestServiceName is the fully-qualified name of the MergeRequestService service.
27 MergeRequestServiceName = "ermite.MergeRequestService"
28)
29
30// These constants are the fully-qualified names of the RPCs defined in this package. They're
31// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
32//
33// Note that these are different from the fully-qualified method names used by
34// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
35// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
36// period.
37const (
38 // MergeRequestServiceCreateMergeRequestProcedure is the fully-qualified name of the
39 // MergeRequestService's CreateMergeRequest RPC.
40 MergeRequestServiceCreateMergeRequestProcedure = "/ermite.MergeRequestService/CreateMergeRequest"
41 // MergeRequestServiceListMergeRequestsProcedure is the fully-qualified name of the
42 // MergeRequestService's ListMergeRequests RPC.
43 MergeRequestServiceListMergeRequestsProcedure = "/ermite.MergeRequestService/ListMergeRequests"
44 // MergeRequestServiceGetMergeRequestProcedure is the fully-qualified name of the
45 // MergeRequestService's GetMergeRequest RPC.
46 MergeRequestServiceGetMergeRequestProcedure = "/ermite.MergeRequestService/GetMergeRequest"
47 // MergeRequestServiceAddCommentProcedure is the fully-qualified name of the MergeRequestService's
48 // AddComment RPC.
49 MergeRequestServiceAddCommentProcedure = "/ermite.MergeRequestService/AddComment"
50 // MergeRequestServiceEditCommentProcedure is the fully-qualified name of the MergeRequestService's
51 // EditComment RPC.
52 MergeRequestServiceEditCommentProcedure = "/ermite.MergeRequestService/EditComment"
53 // MergeRequestServiceDeleteCommentProcedure is the fully-qualified name of the
54 // MergeRequestService's DeleteComment RPC.
55 MergeRequestServiceDeleteCommentProcedure = "/ermite.MergeRequestService/DeleteComment"
56 // MergeRequestServiceResolveCommentProcedure is the fully-qualified name of the
57 // MergeRequestService's ResolveComment RPC.
58 MergeRequestServiceResolveCommentProcedure = "/ermite.MergeRequestService/ResolveComment"
59 // MergeRequestServiceCloseMergeRequestProcedure is the fully-qualified name of the
60 // MergeRequestService's CloseMergeRequest RPC.
61 MergeRequestServiceCloseMergeRequestProcedure = "/ermite.MergeRequestService/CloseMergeRequest"
62 // MergeRequestServiceMarkReadyProcedure is the fully-qualified name of the MergeRequestService's
63 // MarkReady RPC.
64 MergeRequestServiceMarkReadyProcedure = "/ermite.MergeRequestService/MarkReady"
65 // MergeRequestServiceMergeMergeRequestProcedure is the fully-qualified name of the
66 // MergeRequestService's MergeMergeRequest RPC.
67 MergeRequestServiceMergeMergeRequestProcedure = "/ermite.MergeRequestService/MergeMergeRequest"
68 // MergeRequestServiceEnableAutoMergeProcedure is the fully-qualified name of the
69 // MergeRequestService's EnableAutoMerge RPC.
70 MergeRequestServiceEnableAutoMergeProcedure = "/ermite.MergeRequestService/EnableAutoMerge"
71 // MergeRequestServiceCancelAutoMergeProcedure is the fully-qualified name of the
72 // MergeRequestService's CancelAutoMerge RPC.
73 MergeRequestServiceCancelAutoMergeProcedure = "/ermite.MergeRequestService/CancelAutoMerge"
74 // MergeRequestServiceMarkReadProcedure is the fully-qualified name of the MergeRequestService's
75 // MarkRead RPC.
76 MergeRequestServiceMarkReadProcedure = "/ermite.MergeRequestService/MarkRead"
77)
78
79// MergeRequestServiceClient is a client for the ermite.MergeRequestService service.
80type MergeRequestServiceClient interface {
81 // CreateMergeRequest opens a merge request. Needs the mr:write scope. Fails
82 // with invalid_argument if a text rule is broken, if a branch does not exist
83 // or if source and target are the same branch, and with already_exists if an
84 // open merge request already has the same source and target.
85 CreateMergeRequest(context.Context, *connect.Request[ermite.CreateMergeRequestRequest]) (*connect.Response[ermite.CreateMergeRequestResponse], error)
86 // ListMergeRequests lists the merge requests of a repository, highest
87 // number (newest) first, optionally restricted to one state. The listed
88 // merge requests carry no diff or comments; head_id is set. Fails with
89 // not_found if the repository does not exist or is not readable.
90 ListMergeRequests(context.Context, *connect.Request[ermite.ListMergeRequestsRequest]) (*connect.Response[ermite.ListMergeRequestsResponse], error)
91 // GetMergeRequest returns one merge request with its commits, its diff and
92 // its comments. The diff compares the target with the head (what the merge
93 // would bring: "target...head"), or, with since_last_read, the head the
94 // caller last marked read with the current head. Fails with not_found if
95 // the repository or the number is unknown.
96 GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error)
97 // AddComment adds a general comment, a comment on a line or a range of
98 // lines of the diff, or a reply to a root comment. Needs the mr:write
99 // scope; setting a verdict also needs the mr:review scope (permission_denied
100 // without it). Fails with invalid_argument if the text breaks a rule (it may
101 // be empty only with a verdict), if path, line, start_line and side do not
102 // designate lines of the current diff of the merge request, if reply_to is
103 // not the id of a root comment that is not deleted, if a reply sets path,
104 // line, start_line, side or verdict, or if a verdict is set on a reply; and
105 // with failed_precondition if the merge request is not open. A comment with
106 // VERDICT_APPROVE is created resolved.
107 AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error)
108 // EditComment replaces the text of a comment. Needs the mr:write scope, and
109 // only the author of the comment can edit it (permission_denied
110 // otherwise). Fails with invalid_argument if the text breaks a rule (it may
111 // be empty only for a comment with a verdict), with not_found if the comment
112 // is unknown, and with failed_precondition if the merge request is not open
113 // or the comment was deleted. Sending the current text succeeds and changes
114 // nothing.
115 EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error)
116 // DeleteComment deletes a comment: its text is emptied and deleted is set,
117 // while its id, anchor, replies and verdict remain. Needs the mr:write
118 // scope, and only the author of the comment can delete it
119 // (permission_denied otherwise). Fails with not_found if the comment is
120 // unknown and with failed_precondition if the merge request is not open.
121 // Deleting a comment already deleted succeeds and changes nothing.
122 DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error)
123 // ResolveComment marks a thread resolved or unresolved. Needs the mr:write
124 // scope. Resolution belongs to the root comment: on a reply it fails with
125 // invalid_argument. Fails with not_found if the comment is unknown and with
126 // failed_precondition if the merge request is not open. Setting the state
127 // the comment already has succeeds and changes nothing.
128 ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error)
129 // CloseMergeRequest closes an open merge request without merging it. Needs
130 // the mr:write scope. Fails with failed_precondition if the merge request
131 // is not open. A closed merge request cannot be reopened: open a new one.
132 CloseMergeRequest(context.Context, *connect.Request[ermite.CloseMergeRequestRequest]) (*connect.Response[ermite.CloseMergeRequestResponse], error)
133 // MarkReady removes the draft prefix ("WIP:" or "[WIP]") from the title so
134 // the merge request can be merged. Needs the mr:write scope. Fails with
135 // failed_precondition if the merge request is not open or is not a draft.
136 // Publishes no event: there is none for a change of title. Needs the
137 // "merge_requests.ready" feature.
138 MarkReady(context.Context, *connect.Request[ermite.MarkReadyRequest]) (*connect.Response[ermite.MarkReadyResponse], error)
139 // MergeMergeRequest merges an open merge request. Needs the mr:merge scope,
140 // which merges only when the checks on the head allow it: none failed and
141 // none queued or running (a head with no checks may be merged; success,
142 // skipped and neutral pass). The mr:force-merge scope allows ignore_checks.
143 // The caller passes the head it reviewed: the server merges only if the
144 // source branch still points to it, so a push between review and merge is
145 // never merged unseen. Fails with invalid_argument if head_id is empty or
146 // not a commit id, and with failed_precondition if the merge request is not
147 // open, if the source branch no longer points to head_id ("branch moved,
148 // read again"), if the mode is fast-forward and the target is not an
149 // ancestor of the head (rebase and push again, or merge with squash or
150 // merge commit), if the mode is squash or merge commit and the head
151 // conflicts with the target or shares no history with it (rebase and push
152 // again), if the mode is not allowed by RepoSettings, or if a check failed or
153 // has not finished, unless ignore_checks is set. Merges of one
154 // repository run one at a time. Repeating a call that succeeded fails with
155 // failed_precondition (not open). On success the server publishes
156 // MergeRequestMerged then Pushed for the target branch.
157 MergeMergeRequest(context.Context, *connect.Request[ermite.MergeMergeRequestRequest]) (*connect.Response[ermite.MergeMergeRequestResponse], error)
158 // EnableAutoMerge asks the server to merge an open merge request by itself
159 // once at least one check passed on its head, every run created on that head
160 // is complete, and no check failed. It does not take ignore_checks. Needs
161 // the mr:merge scope and, for a token limited to branches, write access to
162 // the target branch
163 // (permission_denied otherwise). The server records the caller, the mode and
164 // the head the caller saw; it merges as the caller, after resolving the caller
165 // again, and cancels the auto-merge if the caller can no longer merge, if the
166 // mode is no longer allowed, if the source branch moves or if the setting is
167 // turned off. Fails with invalid_argument if the mode is not a merge mode or
168 // if head_id is empty or not a commit id, and with failed_precondition if the
169 // merge request is not open, if the source branch no longer points to head_id
170 // ("branch moved, read again"), is a draft,
171 // RepoSettings.allow_auto_merge is off, the mode is not allowed by
172 // RepoSettings, or the server has no CI. Enabling again replaces the mode.
173 // Publishes MergeRequestAutoMergeEnabled. Needs the
174 // "merge_requests.auto_merge" feature.
175 EnableAutoMerge(context.Context, *connect.Request[ermite.EnableAutoMergeRequest]) (*connect.Response[ermite.EnableAutoMergeResponse], error)
176 // CancelAutoMerge cancels the pending auto-merge of an open merge request.
177 // Needs the mr:merge scope and, for a token limited to branches, write access
178 // to the target branch. Fails with failed_precondition if auto-merge is not
179 // enabled. Publishes MergeRequestAutoMergeCancelled.
180 CancelAutoMerge(context.Context, *connect.Request[ermite.CancelAutoMergeRequest]) (*connect.Response[ermite.CancelAutoMergeResponse], error)
181 // MarkRead records the head the caller has reviewed, for the since_last_read
182 // option of GetMergeRequest. There is one read position per merge request,
183 // the reviewer's. Needs the mr:write scope. Marking a commit that does not
184 // exist in the repository is invalid_argument.
185 MarkRead(context.Context, *connect.Request[ermite.MarkReadRequest]) (*connect.Response[ermite.MarkReadResponse], error)
186}
187
188// NewMergeRequestServiceClient constructs a client for the ermite.MergeRequestService service. By
189// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
190// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
191// connect.WithGRPC() or connect.WithGRPCWeb() options.
192//
193// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
194// http://api.acme.com or https://acme.com/grpc).
195func NewMergeRequestServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MergeRequestServiceClient {
196 baseURL = strings.TrimRight(baseURL, "/")
197 mergeRequestServiceMethods := ermite.File_ermite_merge_request_proto.Services().ByName("MergeRequestService").Methods()
198 return &mergeRequestServiceClient{
199 createMergeRequest: connect.NewClient[ermite.CreateMergeRequestRequest, ermite.CreateMergeRequestResponse](
200 httpClient,
201 baseURL+MergeRequestServiceCreateMergeRequestProcedure,
202 connect.WithSchema(mergeRequestServiceMethods.ByName("CreateMergeRequest")),
203 connect.WithClientOptions(opts...),
204 ),
205 listMergeRequests: connect.NewClient[ermite.ListMergeRequestsRequest, ermite.ListMergeRequestsResponse](
206 httpClient,
207 baseURL+MergeRequestServiceListMergeRequestsProcedure,
208 connect.WithSchema(mergeRequestServiceMethods.ByName("ListMergeRequests")),
209 connect.WithClientOptions(opts...),
210 ),
211 getMergeRequest: connect.NewClient[ermite.GetMergeRequestRequest, ermite.GetMergeRequestResponse](
212 httpClient,
213 baseURL+MergeRequestServiceGetMergeRequestProcedure,
214 connect.WithSchema(mergeRequestServiceMethods.ByName("GetMergeRequest")),
215 connect.WithClientOptions(opts...),
216 ),
217 addComment: connect.NewClient[ermite.AddCommentRequest, ermite.AddCommentResponse](
218 httpClient,
219 baseURL+MergeRequestServiceAddCommentProcedure,
220 connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")),
221 connect.WithClientOptions(opts...),
222 ),
223 editComment: connect.NewClient[ermite.EditCommentRequest, ermite.EditCommentResponse](
224 httpClient,
225 baseURL+MergeRequestServiceEditCommentProcedure,
226 connect.WithSchema(mergeRequestServiceMethods.ByName("EditComment")),
227 connect.WithClientOptions(opts...),
228 ),
229 deleteComment: connect.NewClient[ermite.DeleteCommentRequest, ermite.DeleteCommentResponse](
230 httpClient,
231 baseURL+MergeRequestServiceDeleteCommentProcedure,
232 connect.WithSchema(mergeRequestServiceMethods.ByName("DeleteComment")),
233 connect.WithClientOptions(opts...),
234 ),
235 resolveComment: connect.NewClient[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse](
236 httpClient,
237 baseURL+MergeRequestServiceResolveCommentProcedure,
238 connect.WithSchema(mergeRequestServiceMethods.ByName("ResolveComment")),
239 connect.WithClientOptions(opts...),
240 ),
241 closeMergeRequest: connect.NewClient[ermite.CloseMergeRequestRequest, ermite.CloseMergeRequestResponse](
242 httpClient,
243 baseURL+MergeRequestServiceCloseMergeRequestProcedure,
244 connect.WithSchema(mergeRequestServiceMethods.ByName("CloseMergeRequest")),
245 connect.WithClientOptions(opts...),
246 ),
247 markReady: connect.NewClient[ermite.MarkReadyRequest, ermite.MarkReadyResponse](
248 httpClient,
249 baseURL+MergeRequestServiceMarkReadyProcedure,
250 connect.WithSchema(mergeRequestServiceMethods.ByName("MarkReady")),
251 connect.WithClientOptions(opts...),
252 ),
253 mergeMergeRequest: connect.NewClient[ermite.MergeMergeRequestRequest, ermite.MergeMergeRequestResponse](
254 httpClient,
255 baseURL+MergeRequestServiceMergeMergeRequestProcedure,
256 connect.WithSchema(mergeRequestServiceMethods.ByName("MergeMergeRequest")),
257 connect.WithClientOptions(opts...),
258 ),
259 enableAutoMerge: connect.NewClient[ermite.EnableAutoMergeRequest, ermite.EnableAutoMergeResponse](
260 httpClient,
261 baseURL+MergeRequestServiceEnableAutoMergeProcedure,
262 connect.WithSchema(mergeRequestServiceMethods.ByName("EnableAutoMerge")),
263 connect.WithClientOptions(opts...),
264 ),
265 cancelAutoMerge: connect.NewClient[ermite.CancelAutoMergeRequest, ermite.CancelAutoMergeResponse](
266 httpClient,
267 baseURL+MergeRequestServiceCancelAutoMergeProcedure,
268 connect.WithSchema(mergeRequestServiceMethods.ByName("CancelAutoMerge")),
269 connect.WithClientOptions(opts...),
270 ),
271 markRead: connect.NewClient[ermite.MarkReadRequest, ermite.MarkReadResponse](
272 httpClient,
273 baseURL+MergeRequestServiceMarkReadProcedure,
274 connect.WithSchema(mergeRequestServiceMethods.ByName("MarkRead")),
275 connect.WithClientOptions(opts...),
276 ),
277 }
278}
279
280// mergeRequestServiceClient implements MergeRequestServiceClient.
281type mergeRequestServiceClient struct {
282 createMergeRequest *connect.Client[ermite.CreateMergeRequestRequest, ermite.CreateMergeRequestResponse]
283 listMergeRequests *connect.Client[ermite.ListMergeRequestsRequest, ermite.ListMergeRequestsResponse]
284 getMergeRequest *connect.Client[ermite.GetMergeRequestRequest, ermite.GetMergeRequestResponse]
285 addComment *connect.Client[ermite.AddCommentRequest, ermite.AddCommentResponse]
286 editComment *connect.Client[ermite.EditCommentRequest, ermite.EditCommentResponse]
287 deleteComment *connect.Client[ermite.DeleteCommentRequest, ermite.DeleteCommentResponse]
288 resolveComment *connect.Client[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse]
289 closeMergeRequest *connect.Client[ermite.CloseMergeRequestRequest, ermite.CloseMergeRequestResponse]
290 markReady *connect.Client[ermite.MarkReadyRequest, ermite.MarkReadyResponse]
291 mergeMergeRequest *connect.Client[ermite.MergeMergeRequestRequest, ermite.MergeMergeRequestResponse]
292 enableAutoMerge *connect.Client[ermite.EnableAutoMergeRequest, ermite.EnableAutoMergeResponse]
293 cancelAutoMerge *connect.Client[ermite.CancelAutoMergeRequest, ermite.CancelAutoMergeResponse]
294 markRead *connect.Client[ermite.MarkReadRequest, ermite.MarkReadResponse]
295}
296
297// CreateMergeRequest calls ermite.MergeRequestService.CreateMergeRequest.
298func (c *mergeRequestServiceClient) CreateMergeRequest(ctx context.Context, req *connect.Request[ermite.CreateMergeRequestRequest]) (*connect.Response[ermite.CreateMergeRequestResponse], error) {
299 return c.createMergeRequest.CallUnary(ctx, req)
300}
301
302// ListMergeRequests calls ermite.MergeRequestService.ListMergeRequests.
303func (c *mergeRequestServiceClient) ListMergeRequests(ctx context.Context, req *connect.Request[ermite.ListMergeRequestsRequest]) (*connect.Response[ermite.ListMergeRequestsResponse], error) {
304 return c.listMergeRequests.CallUnary(ctx, req)
305}
306
307// GetMergeRequest calls ermite.MergeRequestService.GetMergeRequest.
308func (c *mergeRequestServiceClient) GetMergeRequest(ctx context.Context, req *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) {
309 return c.getMergeRequest.CallUnary(ctx, req)
310}
311
312// AddComment calls ermite.MergeRequestService.AddComment.
313func (c *mergeRequestServiceClient) AddComment(ctx context.Context, req *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) {
314 return c.addComment.CallUnary(ctx, req)
315}
316
317// EditComment calls ermite.MergeRequestService.EditComment.
318func (c *mergeRequestServiceClient) EditComment(ctx context.Context, req *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) {
319 return c.editComment.CallUnary(ctx, req)
320}
321
322// DeleteComment calls ermite.MergeRequestService.DeleteComment.
323func (c *mergeRequestServiceClient) DeleteComment(ctx context.Context, req *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) {
324 return c.deleteComment.CallUnary(ctx, req)
325}
326
327// ResolveComment calls ermite.MergeRequestService.ResolveComment.
328func (c *mergeRequestServiceClient) ResolveComment(ctx context.Context, req *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) {
329 return c.resolveComment.CallUnary(ctx, req)
330}
331
332// CloseMergeRequest calls ermite.MergeRequestService.CloseMergeRequest.
333func (c *mergeRequestServiceClient) CloseMergeRequest(ctx context.Context, req *connect.Request[ermite.CloseMergeRequestRequest]) (*connect.Response[ermite.CloseMergeRequestResponse], error) {
334 return c.closeMergeRequest.CallUnary(ctx, req)
335}
336
337// MarkReady calls ermite.MergeRequestService.MarkReady.
338func (c *mergeRequestServiceClient) MarkReady(ctx context.Context, req *connect.Request[ermite.MarkReadyRequest]) (*connect.Response[ermite.MarkReadyResponse], error) {
339 return c.markReady.CallUnary(ctx, req)
340}
341
342// MergeMergeRequest calls ermite.MergeRequestService.MergeMergeRequest.
343func (c *mergeRequestServiceClient) MergeMergeRequest(ctx context.Context, req *connect.Request[ermite.MergeMergeRequestRequest]) (*connect.Response[ermite.MergeMergeRequestResponse], error) {
344 return c.mergeMergeRequest.CallUnary(ctx, req)
345}
346
347// EnableAutoMerge calls ermite.MergeRequestService.EnableAutoMerge.
348func (c *mergeRequestServiceClient) EnableAutoMerge(ctx context.Context, req *connect.Request[ermite.EnableAutoMergeRequest]) (*connect.Response[ermite.EnableAutoMergeResponse], error) {
349 return c.enableAutoMerge.CallUnary(ctx, req)
350}
351
352// CancelAutoMerge calls ermite.MergeRequestService.CancelAutoMerge.
353func (c *mergeRequestServiceClient) CancelAutoMerge(ctx context.Context, req *connect.Request[ermite.CancelAutoMergeRequest]) (*connect.Response[ermite.CancelAutoMergeResponse], error) {
354 return c.cancelAutoMerge.CallUnary(ctx, req)
355}
356
357// MarkRead calls ermite.MergeRequestService.MarkRead.
358func (c *mergeRequestServiceClient) MarkRead(ctx context.Context, req *connect.Request[ermite.MarkReadRequest]) (*connect.Response[ermite.MarkReadResponse], error) {
359 return c.markRead.CallUnary(ctx, req)
360}
361
362// MergeRequestServiceHandler is an implementation of the ermite.MergeRequestService service.
363type MergeRequestServiceHandler interface {
364 // CreateMergeRequest opens a merge request. Needs the mr:write scope. Fails
365 // with invalid_argument if a text rule is broken, if a branch does not exist
366 // or if source and target are the same branch, and with already_exists if an
367 // open merge request already has the same source and target.
368 CreateMergeRequest(context.Context, *connect.Request[ermite.CreateMergeRequestRequest]) (*connect.Response[ermite.CreateMergeRequestResponse], error)
369 // ListMergeRequests lists the merge requests of a repository, highest
370 // number (newest) first, optionally restricted to one state. The listed
371 // merge requests carry no diff or comments; head_id is set. Fails with
372 // not_found if the repository does not exist or is not readable.
373 ListMergeRequests(context.Context, *connect.Request[ermite.ListMergeRequestsRequest]) (*connect.Response[ermite.ListMergeRequestsResponse], error)
374 // GetMergeRequest returns one merge request with its commits, its diff and
375 // its comments. The diff compares the target with the head (what the merge
376 // would bring: "target...head"), or, with since_last_read, the head the
377 // caller last marked read with the current head. Fails with not_found if
378 // the repository or the number is unknown.
379 GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error)
380 // AddComment adds a general comment, a comment on a line or a range of
381 // lines of the diff, or a reply to a root comment. Needs the mr:write
382 // scope; setting a verdict also needs the mr:review scope (permission_denied
383 // without it). Fails with invalid_argument if the text breaks a rule (it may
384 // be empty only with a verdict), if path, line, start_line and side do not
385 // designate lines of the current diff of the merge request, if reply_to is
386 // not the id of a root comment that is not deleted, if a reply sets path,
387 // line, start_line, side or verdict, or if a verdict is set on a reply; and
388 // with failed_precondition if the merge request is not open. A comment with
389 // VERDICT_APPROVE is created resolved.
390 AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error)
391 // EditComment replaces the text of a comment. Needs the mr:write scope, and
392 // only the author of the comment can edit it (permission_denied
393 // otherwise). Fails with invalid_argument if the text breaks a rule (it may
394 // be empty only for a comment with a verdict), with not_found if the comment
395 // is unknown, and with failed_precondition if the merge request is not open
396 // or the comment was deleted. Sending the current text succeeds and changes
397 // nothing.
398 EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error)
399 // DeleteComment deletes a comment: its text is emptied and deleted is set,
400 // while its id, anchor, replies and verdict remain. Needs the mr:write
401 // scope, and only the author of the comment can delete it
402 // (permission_denied otherwise). Fails with not_found if the comment is
403 // unknown and with failed_precondition if the merge request is not open.
404 // Deleting a comment already deleted succeeds and changes nothing.
405 DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error)
406 // ResolveComment marks a thread resolved or unresolved. Needs the mr:write
407 // scope. Resolution belongs to the root comment: on a reply it fails with
408 // invalid_argument. Fails with not_found if the comment is unknown and with
409 // failed_precondition if the merge request is not open. Setting the state
410 // the comment already has succeeds and changes nothing.
411 ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error)
412 // CloseMergeRequest closes an open merge request without merging it. Needs
413 // the mr:write scope. Fails with failed_precondition if the merge request
414 // is not open. A closed merge request cannot be reopened: open a new one.
415 CloseMergeRequest(context.Context, *connect.Request[ermite.CloseMergeRequestRequest]) (*connect.Response[ermite.CloseMergeRequestResponse], error)
416 // MarkReady removes the draft prefix ("WIP:" or "[WIP]") from the title so
417 // the merge request can be merged. Needs the mr:write scope. Fails with
418 // failed_precondition if the merge request is not open or is not a draft.
419 // Publishes no event: there is none for a change of title. Needs the
420 // "merge_requests.ready" feature.
421 MarkReady(context.Context, *connect.Request[ermite.MarkReadyRequest]) (*connect.Response[ermite.MarkReadyResponse], error)
422 // MergeMergeRequest merges an open merge request. Needs the mr:merge scope,
423 // which merges only when the checks on the head allow it: none failed and
424 // none queued or running (a head with no checks may be merged; success,
425 // skipped and neutral pass). The mr:force-merge scope allows ignore_checks.
426 // The caller passes the head it reviewed: the server merges only if the
427 // source branch still points to it, so a push between review and merge is
428 // never merged unseen. Fails with invalid_argument if head_id is empty or
429 // not a commit id, and with failed_precondition if the merge request is not
430 // open, if the source branch no longer points to head_id ("branch moved,
431 // read again"), if the mode is fast-forward and the target is not an
432 // ancestor of the head (rebase and push again, or merge with squash or
433 // merge commit), if the mode is squash or merge commit and the head
434 // conflicts with the target or shares no history with it (rebase and push
435 // again), if the mode is not allowed by RepoSettings, or if a check failed or
436 // has not finished, unless ignore_checks is set. Merges of one
437 // repository run one at a time. Repeating a call that succeeded fails with
438 // failed_precondition (not open). On success the server publishes
439 // MergeRequestMerged then Pushed for the target branch.
440 MergeMergeRequest(context.Context, *connect.Request[ermite.MergeMergeRequestRequest]) (*connect.Response[ermite.MergeMergeRequestResponse], error)
441 // EnableAutoMerge asks the server to merge an open merge request by itself
442 // once at least one check passed on its head, every run created on that head
443 // is complete, and no check failed. It does not take ignore_checks. Needs
444 // the mr:merge scope and, for a token limited to branches, write access to
445 // the target branch
446 // (permission_denied otherwise). The server records the caller, the mode and
447 // the head the caller saw; it merges as the caller, after resolving the caller
448 // again, and cancels the auto-merge if the caller can no longer merge, if the
449 // mode is no longer allowed, if the source branch moves or if the setting is
450 // turned off. Fails with invalid_argument if the mode is not a merge mode or
451 // if head_id is empty or not a commit id, and with failed_precondition if the
452 // merge request is not open, if the source branch no longer points to head_id
453 // ("branch moved, read again"), is a draft,
454 // RepoSettings.allow_auto_merge is off, the mode is not allowed by
455 // RepoSettings, or the server has no CI. Enabling again replaces the mode.
456 // Publishes MergeRequestAutoMergeEnabled. Needs the
457 // "merge_requests.auto_merge" feature.
458 EnableAutoMerge(context.Context, *connect.Request[ermite.EnableAutoMergeRequest]) (*connect.Response[ermite.EnableAutoMergeResponse], error)
459 // CancelAutoMerge cancels the pending auto-merge of an open merge request.
460 // Needs the mr:merge scope and, for a token limited to branches, write access
461 // to the target branch. Fails with failed_precondition if auto-merge is not
462 // enabled. Publishes MergeRequestAutoMergeCancelled.
463 CancelAutoMerge(context.Context, *connect.Request[ermite.CancelAutoMergeRequest]) (*connect.Response[ermite.CancelAutoMergeResponse], error)
464 // MarkRead records the head the caller has reviewed, for the since_last_read
465 // option of GetMergeRequest. There is one read position per merge request,
466 // the reviewer's. Needs the mr:write scope. Marking a commit that does not
467 // exist in the repository is invalid_argument.
468 MarkRead(context.Context, *connect.Request[ermite.MarkReadRequest]) (*connect.Response[ermite.MarkReadResponse], error)
469}
470
471// NewMergeRequestServiceHandler builds an HTTP handler from the service implementation. It returns
472// the path on which to mount the handler and the handler itself.
473//
474// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
475// and JSON codecs. They also support gzip compression.
476func NewMergeRequestServiceHandler(svc MergeRequestServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
477 mergeRequestServiceMethods := ermite.File_ermite_merge_request_proto.Services().ByName("MergeRequestService").Methods()
478 mergeRequestServiceCreateMergeRequestHandler := connect.NewUnaryHandler(
479 MergeRequestServiceCreateMergeRequestProcedure,
480 svc.CreateMergeRequest,
481 connect.WithSchema(mergeRequestServiceMethods.ByName("CreateMergeRequest")),
482 connect.WithHandlerOptions(opts...),
483 )
484 mergeRequestServiceListMergeRequestsHandler := connect.NewUnaryHandler(
485 MergeRequestServiceListMergeRequestsProcedure,
486 svc.ListMergeRequests,
487 connect.WithSchema(mergeRequestServiceMethods.ByName("ListMergeRequests")),
488 connect.WithHandlerOptions(opts...),
489 )
490 mergeRequestServiceGetMergeRequestHandler := connect.NewUnaryHandler(
491 MergeRequestServiceGetMergeRequestProcedure,
492 svc.GetMergeRequest,
493 connect.WithSchema(mergeRequestServiceMethods.ByName("GetMergeRequest")),
494 connect.WithHandlerOptions(opts...),
495 )
496 mergeRequestServiceAddCommentHandler := connect.NewUnaryHandler(
497 MergeRequestServiceAddCommentProcedure,
498 svc.AddComment,
499 connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")),
500 connect.WithHandlerOptions(opts...),
501 )
502 mergeRequestServiceEditCommentHandler := connect.NewUnaryHandler(
503 MergeRequestServiceEditCommentProcedure,
504 svc.EditComment,
505 connect.WithSchema(mergeRequestServiceMethods.ByName("EditComment")),
506 connect.WithHandlerOptions(opts...),
507 )
508 mergeRequestServiceDeleteCommentHandler := connect.NewUnaryHandler(
509 MergeRequestServiceDeleteCommentProcedure,
510 svc.DeleteComment,
511 connect.WithSchema(mergeRequestServiceMethods.ByName("DeleteComment")),
512 connect.WithHandlerOptions(opts...),
513 )
514 mergeRequestServiceResolveCommentHandler := connect.NewUnaryHandler(
515 MergeRequestServiceResolveCommentProcedure,
516 svc.ResolveComment,
517 connect.WithSchema(mergeRequestServiceMethods.ByName("ResolveComment")),
518 connect.WithHandlerOptions(opts...),
519 )
520 mergeRequestServiceCloseMergeRequestHandler := connect.NewUnaryHandler(
521 MergeRequestServiceCloseMergeRequestProcedure,
522 svc.CloseMergeRequest,
523 connect.WithSchema(mergeRequestServiceMethods.ByName("CloseMergeRequest")),
524 connect.WithHandlerOptions(opts...),
525 )
526 mergeRequestServiceMarkReadyHandler := connect.NewUnaryHandler(
527 MergeRequestServiceMarkReadyProcedure,
528 svc.MarkReady,
529 connect.WithSchema(mergeRequestServiceMethods.ByName("MarkReady")),
530 connect.WithHandlerOptions(opts...),
531 )
532 mergeRequestServiceMergeMergeRequestHandler := connect.NewUnaryHandler(
533 MergeRequestServiceMergeMergeRequestProcedure,
534 svc.MergeMergeRequest,
535 connect.WithSchema(mergeRequestServiceMethods.ByName("MergeMergeRequest")),
536 connect.WithHandlerOptions(opts...),
537 )
538 mergeRequestServiceEnableAutoMergeHandler := connect.NewUnaryHandler(
539 MergeRequestServiceEnableAutoMergeProcedure,
540 svc.EnableAutoMerge,
541 connect.WithSchema(mergeRequestServiceMethods.ByName("EnableAutoMerge")),
542 connect.WithHandlerOptions(opts...),
543 )
544 mergeRequestServiceCancelAutoMergeHandler := connect.NewUnaryHandler(
545 MergeRequestServiceCancelAutoMergeProcedure,
546 svc.CancelAutoMerge,
547 connect.WithSchema(mergeRequestServiceMethods.ByName("CancelAutoMerge")),
548 connect.WithHandlerOptions(opts...),
549 )
550 mergeRequestServiceMarkReadHandler := connect.NewUnaryHandler(
551 MergeRequestServiceMarkReadProcedure,
552 svc.MarkRead,
553 connect.WithSchema(mergeRequestServiceMethods.ByName("MarkRead")),
554 connect.WithHandlerOptions(opts...),
555 )
556 return "/ermite.MergeRequestService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
557 switch r.URL.Path {
558 case MergeRequestServiceCreateMergeRequestProcedure:
559 mergeRequestServiceCreateMergeRequestHandler.ServeHTTP(w, r)
560 case MergeRequestServiceListMergeRequestsProcedure:
561 mergeRequestServiceListMergeRequestsHandler.ServeHTTP(w, r)
562 case MergeRequestServiceGetMergeRequestProcedure:
563 mergeRequestServiceGetMergeRequestHandler.ServeHTTP(w, r)
564 case MergeRequestServiceAddCommentProcedure:
565 mergeRequestServiceAddCommentHandler.ServeHTTP(w, r)
566 case MergeRequestServiceEditCommentProcedure:
567 mergeRequestServiceEditCommentHandler.ServeHTTP(w, r)
568 case MergeRequestServiceDeleteCommentProcedure:
569 mergeRequestServiceDeleteCommentHandler.ServeHTTP(w, r)
570 case MergeRequestServiceResolveCommentProcedure:
571 mergeRequestServiceResolveCommentHandler.ServeHTTP(w, r)
572 case MergeRequestServiceCloseMergeRequestProcedure:
573 mergeRequestServiceCloseMergeRequestHandler.ServeHTTP(w, r)
574 case MergeRequestServiceMarkReadyProcedure:
575 mergeRequestServiceMarkReadyHandler.ServeHTTP(w, r)
576 case MergeRequestServiceMergeMergeRequestProcedure:
577 mergeRequestServiceMergeMergeRequestHandler.ServeHTTP(w, r)
578 case MergeRequestServiceEnableAutoMergeProcedure:
579 mergeRequestServiceEnableAutoMergeHandler.ServeHTTP(w, r)
580 case MergeRequestServiceCancelAutoMergeProcedure:
581 mergeRequestServiceCancelAutoMergeHandler.ServeHTTP(w, r)
582 case MergeRequestServiceMarkReadProcedure:
583 mergeRequestServiceMarkReadHandler.ServeHTTP(w, r)
584 default:
585 http.NotFound(w, r)
586 }
587 })
588}
589
590// UnimplementedMergeRequestServiceHandler returns CodeUnimplemented from all methods.
591type UnimplementedMergeRequestServiceHandler struct{}
592
593func (UnimplementedMergeRequestServiceHandler) CreateMergeRequest(context.Context, *connect.Request[ermite.CreateMergeRequestRequest]) (*connect.Response[ermite.CreateMergeRequestResponse], error) {
594 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.CreateMergeRequest is not implemented"))
595}
596
597func (UnimplementedMergeRequestServiceHandler) ListMergeRequests(context.Context, *connect.Request[ermite.ListMergeRequestsRequest]) (*connect.Response[ermite.ListMergeRequestsResponse], error) {
598 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.ListMergeRequests is not implemented"))
599}
600
601func (UnimplementedMergeRequestServiceHandler) GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) {
602 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.GetMergeRequest is not implemented"))
603}
604
605func (UnimplementedMergeRequestServiceHandler) AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) {
606 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.AddComment is not implemented"))
607}
608
609func (UnimplementedMergeRequestServiceHandler) EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) {
610 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.EditComment is not implemented"))
611}
612
613func (UnimplementedMergeRequestServiceHandler) DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) {
614 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.DeleteComment is not implemented"))
615}
616
617func (UnimplementedMergeRequestServiceHandler) ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) {
618 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.ResolveComment is not implemented"))
619}
620
621func (UnimplementedMergeRequestServiceHandler) CloseMergeRequest(context.Context, *connect.Request[ermite.CloseMergeRequestRequest]) (*connect.Response[ermite.CloseMergeRequestResponse], error) {
622 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.CloseMergeRequest is not implemented"))
623}
624
625func (UnimplementedMergeRequestServiceHandler) MarkReady(context.Context, *connect.Request[ermite.MarkReadyRequest]) (*connect.Response[ermite.MarkReadyResponse], error) {
626 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.MarkReady is not implemented"))
627}
628
629func (UnimplementedMergeRequestServiceHandler) MergeMergeRequest(context.Context, *connect.Request[ermite.MergeMergeRequestRequest]) (*connect.Response[ermite.MergeMergeRequestResponse], error) {
630 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.MergeMergeRequest is not implemented"))
631}
632
633func (UnimplementedMergeRequestServiceHandler) EnableAutoMerge(context.Context, *connect.Request[ermite.EnableAutoMergeRequest]) (*connect.Response[ermite.EnableAutoMergeResponse], error) {
634 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.EnableAutoMerge is not implemented"))
635}
636
637func (UnimplementedMergeRequestServiceHandler) CancelAutoMerge(context.Context, *connect.Request[ermite.CancelAutoMergeRequest]) (*connect.Response[ermite.CancelAutoMergeResponse], error) {
638 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.CancelAutoMerge is not implemented"))
639}
640
641func (UnimplementedMergeRequestServiceHandler) MarkRead(context.Context, *connect.Request[ermite.MarkReadRequest]) (*connect.Response[ermite.MarkReadResponse], error) {
642 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.MarkRead is not implemented"))
643}