|
| @@ -47,6 +47,12 @@ const ( |
| 47 | | // MergeRequestServiceAddCommentProcedure is the fully-qualified name of the MergeRequestService's | 47 | | // MergeRequestServiceAddCommentProcedure is the fully-qualified name of the MergeRequestService's |
| 48 | | // AddComment RPC. | 48 | | // AddComment RPC. |
| 49 | | MergeRequestServiceAddCommentProcedure = "/ermite.MergeRequestService/AddComment" | 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" |
| 50 | | // MergeRequestServiceResolveCommentProcedure is the fully-qualified name of the | 56 | | // MergeRequestServiceResolveCommentProcedure is the fully-qualified name of the |
| 51 | | // MergeRequestService's ResolveComment RPC. | 57 | | // MergeRequestService's ResolveComment RPC. |
| 52 | | MergeRequestServiceResolveCommentProcedure = "/ermite.MergeRequestService/ResolveComment" | 58 | | MergeRequestServiceResolveCommentProcedure = "/ermite.MergeRequestService/ResolveComment" |
|
| @@ -79,14 +85,35 @@ type MergeRequestServiceClient interface { |
| 79 | | // caller last marked read with the current head. Fails with not_found if | 85 | | // caller last marked read with the current head. Fails with not_found if |
| 80 | | // the repository or the number is unknown. | 86 | | // the repository or the number is unknown. |
| 81 | | GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) | 87 | | GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) |
| 82 | - | // AddComment adds a general comment or a comment on a line of the diff. | 88 | + | // AddComment adds a general comment, a comment on a line or a range of |
| 83 | - | // Needs the mr:write scope. Fails with invalid_argument if the text breaks | 89 | + | // lines of the diff, or a reply to a root comment. Needs the mr:write |
| 84 | - | // a rule or if path, line and side do not designate a line of the current | 90 | + | // scope; setting a verdict also needs the mr:review scope (permission_denied |
| 85 | - | // diff of the merge request, and with failed_precondition if the merge | 91 | + | // without it). Fails with invalid_argument if the text breaks a rule (it may |
| 86 | - | // request is not open. | 92 | + | // be empty only with a verdict), if path, line, start_line and side do not |
| | | 93 | + | // designate lines of the current diff of the merge request, if reply_to is |
| | | 94 | + | // not the id of a root comment that is not deleted, if a reply sets path, |
| | | 95 | + | // line, start_line, side or verdict, or if a verdict is set on a reply; and |
| | | 96 | + | // with failed_precondition if the merge request is not open. A comment with |
| | | 97 | + | // VERDICT_APPROVE is created resolved. |
| 87 | | AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) | 98 | | AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) |
| 88 | - | // ResolveComment marks a comment resolved or unresolved. Needs the mr:write | 99 | + | // EditComment replaces the text of a comment. Needs the mr:write scope, and |
| 89 | - | // scope. Fails with not_found if the comment is unknown and with | 100 | + | // only the author of the comment can edit it (permission_denied |
| | | 101 | + | // otherwise). Fails with invalid_argument if the text breaks a rule (it may |
| | | 102 | + | // be empty only for a comment with a verdict), with not_found if the comment |
| | | 103 | + | // is unknown, and with failed_precondition if the merge request is not open |
| | | 104 | + | // or the comment was deleted. Sending the current text succeeds and changes |
| | | 105 | + | // nothing. |
| | | 106 | + | EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) |
| | | 107 | + | // DeleteComment deletes a comment: its text is emptied and deleted is set, |
| | | 108 | + | // while its id, anchor, replies and verdict remain. Needs the mr:write |
| | | 109 | + | // scope, and only the author of the comment can delete it |
| | | 110 | + | // (permission_denied otherwise). Fails with not_found if the comment is |
| | | 111 | + | // unknown and with failed_precondition if the merge request is not open. |
| | | 112 | + | // Deleting a comment already deleted succeeds and changes nothing. |
| | | 113 | + | DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) |
| | | 114 | + | // ResolveComment marks a thread resolved or unresolved. Needs the mr:write |
| | | 115 | + | // scope. Resolution belongs to the root comment: on a reply it fails with |
| | | 116 | + | // invalid_argument. Fails with not_found if the comment is unknown and with |
| 90 | | // failed_precondition if the merge request is not open. Setting the state | 117 | | // failed_precondition if the merge request is not open. Setting the state |
| 91 | | // the comment already has succeeds and changes nothing. | 118 | | // the comment already has succeeds and changes nothing. |
| 92 | | ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) | 119 | | ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) |
|
| @@ -149,6 +176,18 @@ func NewMergeRequestServiceClient(httpClient connect.HTTPClient, baseURL string, |
| 149 | | connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")), | 176 | | connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")), |
| 150 | | connect.WithClientOptions(opts...), | 177 | | connect.WithClientOptions(opts...), |
| 151 | | ), | 178 | | ), |
| | | 179 | + | editComment: connect.NewClient[ermite.EditCommentRequest, ermite.EditCommentResponse]( |
| | | 180 | + | httpClient, |
| | | 181 | + | baseURL+MergeRequestServiceEditCommentProcedure, |
| | | 182 | + | connect.WithSchema(mergeRequestServiceMethods.ByName("EditComment")), |
| | | 183 | + | connect.WithClientOptions(opts...), |
| | | 184 | + | ), |
| | | 185 | + | deleteComment: connect.NewClient[ermite.DeleteCommentRequest, ermite.DeleteCommentResponse]( |
| | | 186 | + | httpClient, |
| | | 187 | + | baseURL+MergeRequestServiceDeleteCommentProcedure, |
| | | 188 | + | connect.WithSchema(mergeRequestServiceMethods.ByName("DeleteComment")), |
| | | 189 | + | connect.WithClientOptions(opts...), |
| | | 190 | + | ), |
| 152 | | resolveComment: connect.NewClient[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse]( | 191 | | resolveComment: connect.NewClient[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse]( |
| 153 | | httpClient, | 192 | | httpClient, |
| 154 | | baseURL+MergeRequestServiceResolveCommentProcedure, | 193 | | baseURL+MergeRequestServiceResolveCommentProcedure, |
|
| @@ -182,6 +221,8 @@ type mergeRequestServiceClient struct { |
| 182 | | listMergeRequests *connect.Client[ermite.ListMergeRequestsRequest, ermite.ListMergeRequestsResponse] | 221 | | listMergeRequests *connect.Client[ermite.ListMergeRequestsRequest, ermite.ListMergeRequestsResponse] |
| 183 | | getMergeRequest *connect.Client[ermite.GetMergeRequestRequest, ermite.GetMergeRequestResponse] | 222 | | getMergeRequest *connect.Client[ermite.GetMergeRequestRequest, ermite.GetMergeRequestResponse] |
| 184 | | addComment *connect.Client[ermite.AddCommentRequest, ermite.AddCommentResponse] | 223 | | addComment *connect.Client[ermite.AddCommentRequest, ermite.AddCommentResponse] |
| | | 224 | + | editComment *connect.Client[ermite.EditCommentRequest, ermite.EditCommentResponse] |
| | | 225 | + | deleteComment *connect.Client[ermite.DeleteCommentRequest, ermite.DeleteCommentResponse] |
| 185 | | resolveComment *connect.Client[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse] | 226 | | resolveComment *connect.Client[ermite.ResolveCommentRequest, ermite.ResolveCommentResponse] |
| 186 | | closeMergeRequest *connect.Client[ermite.CloseMergeRequestRequest, ermite.CloseMergeRequestResponse] | 227 | | closeMergeRequest *connect.Client[ermite.CloseMergeRequestRequest, ermite.CloseMergeRequestResponse] |
| 187 | | mergeMergeRequest *connect.Client[ermite.MergeMergeRequestRequest, ermite.MergeMergeRequestResponse] | 228 | | mergeMergeRequest *connect.Client[ermite.MergeMergeRequestRequest, ermite.MergeMergeRequestResponse] |
|
| @@ -208,6 +249,16 @@ func (c *mergeRequestServiceClient) AddComment(ctx context.Context, req *connect |
| 208 | | return c.addComment.CallUnary(ctx, req) | 249 | | return c.addComment.CallUnary(ctx, req) |
| 209 | | } | 250 | | } |
| 210 | | | 251 | | |
| | | 252 | + | // EditComment calls ermite.MergeRequestService.EditComment. |
| | | 253 | + | func (c *mergeRequestServiceClient) EditComment(ctx context.Context, req *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) { |
| | | 254 | + | return c.editComment.CallUnary(ctx, req) |
| | | 255 | + | } |
| | | 256 | + | |
| | | 257 | + | // DeleteComment calls ermite.MergeRequestService.DeleteComment. |
| | | 258 | + | func (c *mergeRequestServiceClient) DeleteComment(ctx context.Context, req *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) { |
| | | 259 | + | return c.deleteComment.CallUnary(ctx, req) |
| | | 260 | + | } |
| | | 261 | + | |
| 211 | | // ResolveComment calls ermite.MergeRequestService.ResolveComment. | 262 | | // ResolveComment calls ermite.MergeRequestService.ResolveComment. |
| 212 | | func (c *mergeRequestServiceClient) ResolveComment(ctx context.Context, req *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) { | 263 | | func (c *mergeRequestServiceClient) ResolveComment(ctx context.Context, req *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) { |
| 213 | | return c.resolveComment.CallUnary(ctx, req) | 264 | | return c.resolveComment.CallUnary(ctx, req) |
|
| @@ -246,14 +297,35 @@ type MergeRequestServiceHandler interface { |
| 246 | | // caller last marked read with the current head. Fails with not_found if | 297 | | // caller last marked read with the current head. Fails with not_found if |
| 247 | | // the repository or the number is unknown. | 298 | | // the repository or the number is unknown. |
| 248 | | GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) | 299 | | GetMergeRequest(context.Context, *connect.Request[ermite.GetMergeRequestRequest]) (*connect.Response[ermite.GetMergeRequestResponse], error) |
| 249 | - | // AddComment adds a general comment or a comment on a line of the diff. | 300 | + | // AddComment adds a general comment, a comment on a line or a range of |
| 250 | - | // Needs the mr:write scope. Fails with invalid_argument if the text breaks | 301 | + | // lines of the diff, or a reply to a root comment. Needs the mr:write |
| 251 | - | // a rule or if path, line and side do not designate a line of the current | 302 | + | // scope; setting a verdict also needs the mr:review scope (permission_denied |
| 252 | - | // diff of the merge request, and with failed_precondition if the merge | 303 | + | // without it). Fails with invalid_argument if the text breaks a rule (it may |
| 253 | - | // request is not open. | 304 | + | // be empty only with a verdict), if path, line, start_line and side do not |
| | | 305 | + | // designate lines of the current diff of the merge request, if reply_to is |
| | | 306 | + | // not the id of a root comment that is not deleted, if a reply sets path, |
| | | 307 | + | // line, start_line, side or verdict, or if a verdict is set on a reply; and |
| | | 308 | + | // with failed_precondition if the merge request is not open. A comment with |
| | | 309 | + | // VERDICT_APPROVE is created resolved. |
| 254 | | AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) | 310 | | AddComment(context.Context, *connect.Request[ermite.AddCommentRequest]) (*connect.Response[ermite.AddCommentResponse], error) |
| 255 | - | // ResolveComment marks a comment resolved or unresolved. Needs the mr:write | 311 | + | // EditComment replaces the text of a comment. Needs the mr:write scope, and |
| 256 | - | // scope. Fails with not_found if the comment is unknown and with | 312 | + | // only the author of the comment can edit it (permission_denied |
| | | 313 | + | // otherwise). Fails with invalid_argument if the text breaks a rule (it may |
| | | 314 | + | // be empty only for a comment with a verdict), with not_found if the comment |
| | | 315 | + | // is unknown, and with failed_precondition if the merge request is not open |
| | | 316 | + | // or the comment was deleted. Sending the current text succeeds and changes |
| | | 317 | + | // nothing. |
| | | 318 | + | EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) |
| | | 319 | + | // DeleteComment deletes a comment: its text is emptied and deleted is set, |
| | | 320 | + | // while its id, anchor, replies and verdict remain. Needs the mr:write |
| | | 321 | + | // scope, and only the author of the comment can delete it |
| | | 322 | + | // (permission_denied otherwise). Fails with not_found if the comment is |
| | | 323 | + | // unknown and with failed_precondition if the merge request is not open. |
| | | 324 | + | // Deleting a comment already deleted succeeds and changes nothing. |
| | | 325 | + | DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) |
| | | 326 | + | // ResolveComment marks a thread resolved or unresolved. Needs the mr:write |
| | | 327 | + | // scope. Resolution belongs to the root comment: on a reply it fails with |
| | | 328 | + | // invalid_argument. Fails with not_found if the comment is unknown and with |
| 257 | | // failed_precondition if the merge request is not open. Setting the state | 329 | | // failed_precondition if the merge request is not open. Setting the state |
| 258 | | // the comment already has succeeds and changes nothing. | 330 | | // the comment already has succeeds and changes nothing. |
| 259 | | ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) | 331 | | ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) |
|
| @@ -312,6 +384,18 @@ func NewMergeRequestServiceHandler(svc MergeRequestServiceHandler, opts ...conne |
| 312 | | connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")), | 384 | | connect.WithSchema(mergeRequestServiceMethods.ByName("AddComment")), |
| 313 | | connect.WithHandlerOptions(opts...), | 385 | | connect.WithHandlerOptions(opts...), |
| 314 | | ) | 386 | | ) |
| | | 387 | + | mergeRequestServiceEditCommentHandler := connect.NewUnaryHandler( |
| | | 388 | + | MergeRequestServiceEditCommentProcedure, |
| | | 389 | + | svc.EditComment, |
| | | 390 | + | connect.WithSchema(mergeRequestServiceMethods.ByName("EditComment")), |
| | | 391 | + | connect.WithHandlerOptions(opts...), |
| | | 392 | + | ) |
| | | 393 | + | mergeRequestServiceDeleteCommentHandler := connect.NewUnaryHandler( |
| | | 394 | + | MergeRequestServiceDeleteCommentProcedure, |
| | | 395 | + | svc.DeleteComment, |
| | | 396 | + | connect.WithSchema(mergeRequestServiceMethods.ByName("DeleteComment")), |
| | | 397 | + | connect.WithHandlerOptions(opts...), |
| | | 398 | + | ) |
| 315 | | mergeRequestServiceResolveCommentHandler := connect.NewUnaryHandler( | 399 | | mergeRequestServiceResolveCommentHandler := connect.NewUnaryHandler( |
| 316 | | MergeRequestServiceResolveCommentProcedure, | 400 | | MergeRequestServiceResolveCommentProcedure, |
| 317 | | svc.ResolveComment, | 401 | | svc.ResolveComment, |
|
| @@ -346,6 +430,10 @@ func NewMergeRequestServiceHandler(svc MergeRequestServiceHandler, opts ...conne |
| 346 | | mergeRequestServiceGetMergeRequestHandler.ServeHTTP(w, r) | 430 | | mergeRequestServiceGetMergeRequestHandler.ServeHTTP(w, r) |
| 347 | | case MergeRequestServiceAddCommentProcedure: | 431 | | case MergeRequestServiceAddCommentProcedure: |
| 348 | | mergeRequestServiceAddCommentHandler.ServeHTTP(w, r) | 432 | | mergeRequestServiceAddCommentHandler.ServeHTTP(w, r) |
| | | 433 | + | case MergeRequestServiceEditCommentProcedure: |
| | | 434 | + | mergeRequestServiceEditCommentHandler.ServeHTTP(w, r) |
| | | 435 | + | case MergeRequestServiceDeleteCommentProcedure: |
| | | 436 | + | mergeRequestServiceDeleteCommentHandler.ServeHTTP(w, r) |
| 349 | | case MergeRequestServiceResolveCommentProcedure: | 437 | | case MergeRequestServiceResolveCommentProcedure: |
| 350 | | mergeRequestServiceResolveCommentHandler.ServeHTTP(w, r) | 438 | | mergeRequestServiceResolveCommentHandler.ServeHTTP(w, r) |
| 351 | | case MergeRequestServiceCloseMergeRequestProcedure: | 439 | | case MergeRequestServiceCloseMergeRequestProcedure: |
|
| @@ -379,6 +467,14 @@ func (UnimplementedMergeRequestServiceHandler) AddComment(context.Context, *conn |
| 379 | | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.AddComment is not implemented")) | 467 | | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.AddComment is not implemented")) |
| 380 | | } | 468 | | } |
| 381 | | | 469 | | |
| | | 470 | + | func (UnimplementedMergeRequestServiceHandler) EditComment(context.Context, *connect.Request[ermite.EditCommentRequest]) (*connect.Response[ermite.EditCommentResponse], error) { |
| | | 471 | + | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.EditComment is not implemented")) |
| | | 472 | + | } |
| | | 473 | + | |
| | | 474 | + | func (UnimplementedMergeRequestServiceHandler) DeleteComment(context.Context, *connect.Request[ermite.DeleteCommentRequest]) (*connect.Response[ermite.DeleteCommentResponse], error) { |
| | | 475 | + | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.DeleteComment is not implemented")) |
| | | 476 | + | } |
| | | 477 | + | |
| 382 | | func (UnimplementedMergeRequestServiceHandler) ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) { | 478 | | func (UnimplementedMergeRequestServiceHandler) ResolveComment(context.Context, *connect.Request[ermite.ResolveCommentRequest]) (*connect.Response[ermite.ResolveCommentResponse], error) { |
| 383 | | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.ResolveComment is not implemented")) | 479 | | return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.MergeRequestService.ResolveComment is not implemented")) |
| 384 | | } | 480 | | } |