feat(proto): require the head the caller saw to enable auto-merge
3 files · +36 -12
M gen/ermite/ermiteconnect/merge_request.connect.go +10 -6
| @@ -149,11 +149,13 @@ type MergeRequestServiceClient interface { | |||
| 149 | 149 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | |
| 150 | 150 | // token limited to branches, write access to the target branch | |
| 151 | 151 | // (permission_denied otherwise). The server records the caller, the mode and | |
| 152 | - | // the current head; it merges as the caller, after resolving the caller | |
| 152 | + | // the head the caller saw; it merges as the caller, after resolving the caller | |
| 153 | 153 | // again, and cancels the auto-merge if the caller can no longer merge, if the | |
| 154 | 154 | // mode is no longer allowed, if the source branch moves or if the setting is | |
| 155 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | |
| 156 | - | // and with failed_precondition if the merge request is not open, is a draft, | |
| 155 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or | |
| 156 | + | // if head_id is empty or not a commit id, and with failed_precondition if the | |
| 157 | + | // merge request is not open, if the source branch no longer points to head_id | |
| 158 | + | // ("branch moved, read again"), is a draft, | |
| 157 | 159 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | |
| 158 | 160 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | |
| 159 | 161 | // Publishes MergeRequestAutoMergeEnabled. Needs the | |
| @@ -409,11 +411,13 @@ type MergeRequestServiceHandler interface { | |||
| 409 | 411 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | |
| 410 | 412 | // token limited to branches, write access to the target branch | |
| 411 | 413 | // (permission_denied otherwise). The server records the caller, the mode and | |
| 412 | - | // the current head; it merges as the caller, after resolving the caller | |
| 414 | + | // the head the caller saw; it merges as the caller, after resolving the caller | |
| 413 | 415 | // again, and cancels the auto-merge if the caller can no longer merge, if the | |
| 414 | 416 | // mode is no longer allowed, if the source branch moves or if the setting is | |
| 415 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | |
| 416 | - | // and with failed_precondition if the merge request is not open, is a draft, | |
| 417 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or | |
| 418 | + | // if head_id is empty or not a commit id, and with failed_precondition if the | |
| 419 | + | // merge request is not open, if the source branch no longer points to head_id | |
| 420 | + | // ("branch moved, read again"), is a draft, | |
| 417 | 421 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | |
| 418 | 422 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | |
| 419 | 423 | // Publishes MergeRequestAutoMergeEnabled. Needs the | |
| @@ -149,11 +149,13 @@ type MergeRequestServiceClient interface { | |||||
| 149 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | 149 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | ||
| 150 | // token limited to branches, write access to the target branch | 150 | // token limited to branches, write access to the target branch | ||
| 151 | // (permission_denied otherwise). The server records the caller, the mode and | 151 | // (permission_denied otherwise). The server records the caller, the mode and | ||
| 152 | - | // the current head; it merges as the caller, after resolving the caller | 152 | + | // the head the caller saw; it merges as the caller, after resolving the caller |
| 153 | // again, and cancels the auto-merge if the caller can no longer merge, if the | 153 | // again, and cancels the auto-merge if the caller can no longer merge, if the | ||
| 154 | // mode is no longer allowed, if the source branch moves or if the setting is | 154 | // mode is no longer allowed, if the source branch moves or if the setting is | ||
| 155 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | 155 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or |
| 156 | - | // and with failed_precondition if the merge request is not open, is a draft, | 156 | + | // if head_id is empty or not a commit id, and with failed_precondition if the |
| 157 | + | // merge request is not open, if the source branch no longer points to head_id | |||
| 158 | + | // ("branch moved, read again"), is a draft, | |||
| 157 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | 159 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | ||
| 158 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | 160 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | ||
| 159 | // Publishes MergeRequestAutoMergeEnabled. Needs the | 161 | // Publishes MergeRequestAutoMergeEnabled. Needs the | ||
| @@ -409,11 +411,13 @@ type MergeRequestServiceHandler interface { | |||||
| 409 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | 411 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | ||
| 410 | // token limited to branches, write access to the target branch | 412 | // token limited to branches, write access to the target branch | ||
| 411 | // (permission_denied otherwise). The server records the caller, the mode and | 413 | // (permission_denied otherwise). The server records the caller, the mode and | ||
| 412 | - | // the current head; it merges as the caller, after resolving the caller | 414 | + | // the head the caller saw; it merges as the caller, after resolving the caller |
| 413 | // again, and cancels the auto-merge if the caller can no longer merge, if the | 415 | // again, and cancels the auto-merge if the caller can no longer merge, if the | ||
| 414 | // mode is no longer allowed, if the source branch moves or if the setting is | 416 | // mode is no longer allowed, if the source branch moves or if the setting is | ||
| 415 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | 417 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or |
| 416 | - | // and with failed_precondition if the merge request is not open, is a draft, | 418 | + | // if head_id is empty or not a commit id, and with failed_precondition if the |
| 419 | + | // merge request is not open, if the source branch no longer points to head_id | |||
| 420 | + | // ("branch moved, read again"), is a draft, | |||
| 417 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | 421 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | ||
| 418 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | 422 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | ||
| 419 | // Publishes MergeRequestAutoMergeEnabled. Needs the | 423 | // Publishes MergeRequestAutoMergeEnabled. Needs the | ||
M gen/ermite/merge_request.pb.go +16 -3
| @@ -2176,7 +2176,12 @@ type EnableAutoMergeRequest struct { | |||
| 2176 | 2176 | Number int64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` | |
| 2177 | 2177 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | |
| 2178 | 2178 | // must be in RepoSettings.allowed_merge_modes of the repository. | |
| 2179 | - | Mode MergeMode `protobuf:"varint,3,opt,name=mode,proto3,enum=ermite.MergeMode" json:"mode,omitempty"` | |
| 2179 | + | Mode MergeMode `protobuf:"varint,3,opt,name=mode,proto3,enum=ermite.MergeMode" json:"mode,omitempty"` | |
| 2180 | + | // HeadId is the full id of the commit the caller reviewed, that is the | |
| 2181 | + | // MergeRequest.head_id it was shown. Required. The auto-merge is enabled | |
| 2182 | + | // only if the source branch still points to it; failed_precondition (branch | |
| 2183 | + | // moved) otherwise. | |
| 2184 | + | HeadId string `protobuf:"bytes,4,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` | |
| 2180 | 2185 | unknownFields protoimpl.UnknownFields | |
| 2181 | 2186 | sizeCache protoimpl.SizeCache | |
| 2182 | 2187 | } | |
| @@ -2232,6 +2237,13 @@ func (x *EnableAutoMergeRequest) GetMode() MergeMode { | |||
| 2232 | 2237 | return MergeMode_MERGE_MODE_UNSPECIFIED | |
| 2233 | 2238 | } | |
| 2234 | 2239 | ||
| 2240 | + | func (x *EnableAutoMergeRequest) GetHeadId() string { | |
| 2241 | + | if x != nil { | |
| 2242 | + | return x.HeadId | |
| 2243 | + | } | |
| 2244 | + | return "" | |
| 2245 | + | } | |
| 2246 | + | ||
| 2235 | 2247 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | |
| 2236 | 2248 | type EnableAutoMergeResponse struct { | |
| 2237 | 2249 | state protoimpl.MessageState `protogen:"open.v1"` | |
| @@ -2638,11 +2650,12 @@ const file_ermite_merge_request_proto_rawDesc = "" + | |||
| 2638 | 2650 | "\x14delete_source_branch\x18\x05 \x01(\bR\x12deleteSourceBranch\"\x8a\x01\n" + | |
| 2639 | 2651 | "\x19MergeMergeRequestResponse\x129\n" + | |
| 2640 | 2652 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\x122\n" + | |
| 2641 | - | "\x15source_branch_deleted\x18\x02 \x01(\bR\x13sourceBranchDeleted\"k\n" + | |
| 2653 | + | "\x15source_branch_deleted\x18\x02 \x01(\bR\x13sourceBranchDeleted\"\x84\x01\n" + | |
| 2642 | 2654 | "\x16EnableAutoMergeRequest\x12\x12\n" + | |
| 2643 | 2655 | "\x04repo\x18\x01 \x01(\tR\x04repo\x12\x16\n" + | |
| 2644 | 2656 | "\x06number\x18\x02 \x01(\x03R\x06number\x12%\n" + | |
| 2645 | - | "\x04mode\x18\x03 \x01(\x0e2\x11.ermite.MergeModeR\x04mode\"T\n" + | |
| 2657 | + | "\x04mode\x18\x03 \x01(\x0e2\x11.ermite.MergeModeR\x04mode\x12\x17\n" + | |
| 2658 | + | "\ahead_id\x18\x04 \x01(\tR\x06headId\"T\n" + | |
| 2646 | 2659 | "\x17EnableAutoMergeResponse\x129\n" + | |
| 2647 | 2660 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\"D\n" + | |
| 2648 | 2661 | "\x16CancelAutoMergeRequest\x12\x12\n" + | |
| @@ -2176,7 +2176,12 @@ type EnableAutoMergeRequest struct { | |||||
| 2176 | Number int64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` | 2176 | Number int64 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` | ||
| 2177 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | 2177 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | ||
| 2178 | // must be in RepoSettings.allowed_merge_modes of the repository. | 2178 | // must be in RepoSettings.allowed_merge_modes of the repository. | ||
| 2179 | - | Mode MergeMode `protobuf:"varint,3,opt,name=mode,proto3,enum=ermite.MergeMode" json:"mode,omitempty"` | 2179 | + | Mode MergeMode `protobuf:"varint,3,opt,name=mode,proto3,enum=ermite.MergeMode" json:"mode,omitempty"` |
| 2180 | + | // HeadId is the full id of the commit the caller reviewed, that is the | |||
| 2181 | + | // MergeRequest.head_id it was shown. Required. The auto-merge is enabled | |||
| 2182 | + | // only if the source branch still points to it; failed_precondition (branch | |||
| 2183 | + | // moved) otherwise. | |||
| 2184 | + | HeadId string `protobuf:"bytes,4,opt,name=head_id,json=headId,proto3" json:"head_id,omitempty"` | |||
| 2180 | unknownFields protoimpl.UnknownFields | 2185 | unknownFields protoimpl.UnknownFields | ||
| 2181 | sizeCache protoimpl.SizeCache | 2186 | sizeCache protoimpl.SizeCache | ||
| 2182 | } | 2187 | } | ||
| @@ -2232,6 +2237,13 @@ func (x *EnableAutoMergeRequest) GetMode() MergeMode { | |||||
| 2232 | return MergeMode_MERGE_MODE_UNSPECIFIED | 2237 | return MergeMode_MERGE_MODE_UNSPECIFIED | ||
| 2233 | } | 2238 | } | ||
| 2234 | 2239 | ||||
| 2240 | + | func (x *EnableAutoMergeRequest) GetHeadId() string { | |||
| 2241 | + | if x != nil { | |||
| 2242 | + | return x.HeadId | |||
| 2243 | + | } | |||
| 2244 | + | return "" | |||
| 2245 | + | } | |||
| 2246 | + | ||||
| 2235 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | 2247 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | ||
| 2236 | type EnableAutoMergeResponse struct { | 2248 | type EnableAutoMergeResponse struct { | ||
| 2237 | state protoimpl.MessageState `protogen:"open.v1"` | 2249 | state protoimpl.MessageState `protogen:"open.v1"` | ||
| @@ -2638,11 +2650,12 @@ const file_ermite_merge_request_proto_rawDesc = "" + | |||||
| 2638 | "\x14delete_source_branch\x18\x05 \x01(\bR\x12deleteSourceBranch\"\x8a\x01\n" + | 2650 | "\x14delete_source_branch\x18\x05 \x01(\bR\x12deleteSourceBranch\"\x8a\x01\n" + | ||
| 2639 | "\x19MergeMergeRequestResponse\x129\n" + | 2651 | "\x19MergeMergeRequestResponse\x129\n" + | ||
| 2640 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\x122\n" + | 2652 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\x122\n" + | ||
| 2641 | - | "\x15source_branch_deleted\x18\x02 \x01(\bR\x13sourceBranchDeleted\"k\n" + | 2653 | + | "\x15source_branch_deleted\x18\x02 \x01(\bR\x13sourceBranchDeleted\"\x84\x01\n" + |
| 2642 | "\x16EnableAutoMergeRequest\x12\x12\n" + | 2654 | "\x16EnableAutoMergeRequest\x12\x12\n" + | ||
| 2643 | "\x04repo\x18\x01 \x01(\tR\x04repo\x12\x16\n" + | 2655 | "\x04repo\x18\x01 \x01(\tR\x04repo\x12\x16\n" + | ||
| 2644 | "\x06number\x18\x02 \x01(\x03R\x06number\x12%\n" + | 2656 | "\x06number\x18\x02 \x01(\x03R\x06number\x12%\n" + | ||
| 2645 | - | "\x04mode\x18\x03 \x01(\x0e2\x11.ermite.MergeModeR\x04mode\"T\n" + | 2657 | + | "\x04mode\x18\x03 \x01(\x0e2\x11.ermite.MergeModeR\x04mode\x12\x17\n" + |
| 2658 | + | "\ahead_id\x18\x04 \x01(\tR\x06headId\"T\n" + | |||
| 2646 | "\x17EnableAutoMergeResponse\x129\n" + | 2659 | "\x17EnableAutoMergeResponse\x129\n" + | ||
| 2647 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\"D\n" + | 2660 | "\rmerge_request\x18\x01 \x01(\v2\x14.ermite.MergeRequestR\fmergeRequest\"D\n" + | ||
| 2648 | "\x16CancelAutoMergeRequest\x12\x12\n" + | 2661 | "\x16CancelAutoMergeRequest\x12\x12\n" + | ||
M proto/ermite/merge_request.proto +10 -3
| @@ -322,11 +322,13 @@ service MergeRequestService { | |||
| 322 | 322 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | |
| 323 | 323 | // token limited to branches, write access to the target branch | |
| 324 | 324 | // (permission_denied otherwise). The server records the caller, the mode and | |
| 325 | - | // the current head; it merges as the caller, after resolving the caller | |
| 325 | + | // the head the caller saw; it merges as the caller, after resolving the caller | |
| 326 | 326 | // again, and cancels the auto-merge if the caller can no longer merge, if the | |
| 327 | 327 | // mode is no longer allowed, if the source branch moves or if the setting is | |
| 328 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | |
| 329 | - | // and with failed_precondition if the merge request is not open, is a draft, | |
| 328 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or | |
| 329 | + | // if head_id is empty or not a commit id, and with failed_precondition if the | |
| 330 | + | // merge request is not open, if the source branch no longer points to head_id | |
| 331 | + | // ("branch moved, read again"), is a draft, | |
| 330 | 332 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | |
| 331 | 333 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | |
| 332 | 334 | // Publishes MergeRequestAutoMergeEnabled. Needs the | |
| @@ -591,6 +593,11 @@ message EnableAutoMergeRequest { | |||
| 591 | 593 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | |
| 592 | 594 | // must be in RepoSettings.allowed_merge_modes of the repository. | |
| 593 | 595 | MergeMode mode = 3; | |
| 596 | + | // HeadId is the full id of the commit the caller reviewed, that is the | |
| 597 | + | // MergeRequest.head_id it was shown. Required. The auto-merge is enabled | |
| 598 | + | // only if the source branch still points to it; failed_precondition (branch | |
| 599 | + | // moved) otherwise. | |
| 600 | + | string head_id = 4; | |
| 594 | 601 | } | |
| 595 | 602 | ||
| 596 | 603 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | |
| @@ -322,11 +322,13 @@ service MergeRequestService { | |||||
| 322 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | 322 | // RepoSettings.failing_checks_block says. Needs the mr:merge scope and, for a | ||
| 323 | // token limited to branches, write access to the target branch | 323 | // token limited to branches, write access to the target branch | ||
| 324 | // (permission_denied otherwise). The server records the caller, the mode and | 324 | // (permission_denied otherwise). The server records the caller, the mode and | ||
| 325 | - | // the current head; it merges as the caller, after resolving the caller | 325 | + | // the head the caller saw; it merges as the caller, after resolving the caller |
| 326 | // again, and cancels the auto-merge if the caller can no longer merge, if the | 326 | // again, and cancels the auto-merge if the caller can no longer merge, if the | ||
| 327 | // mode is no longer allowed, if the source branch moves or if the setting is | 327 | // mode is no longer allowed, if the source branch moves or if the setting is | ||
| 328 | - | // turned off. Fails with invalid_argument if the mode is not a merge mode, | 328 | + | // turned off. Fails with invalid_argument if the mode is not a merge mode or |
| 329 | - | // and with failed_precondition if the merge request is not open, is a draft, | 329 | + | // if head_id is empty or not a commit id, and with failed_precondition if the |
| 330 | + | // merge request is not open, if the source branch no longer points to head_id | |||
| 331 | + | // ("branch moved, read again"), is a draft, | |||
| 330 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | 332 | // RepoSettings.allow_auto_merge is off, the mode is not allowed by | ||
| 331 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | 333 | // RepoSettings, or the server has no CI. Enabling again replaces the mode. | ||
| 332 | // Publishes MergeRequestAutoMergeEnabled. Needs the | 334 | // Publishes MergeRequestAutoMergeEnabled. Needs the | ||
| @@ -591,6 +593,11 @@ message EnableAutoMergeRequest { | |||||
| 591 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | 593 | // Mode is how to merge. MERGE_MODE_UNSPECIFIED means fast-forward. The mode | ||
| 592 | // must be in RepoSettings.allowed_merge_modes of the repository. | 594 | // must be in RepoSettings.allowed_merge_modes of the repository. | ||
| 593 | MergeMode mode = 3; | 595 | MergeMode mode = 3; | ||
| 596 | + | // HeadId is the full id of the commit the caller reviewed, that is the | |||
| 597 | + | // MergeRequest.head_id it was shown. Required. The auto-merge is enabled | |||
| 598 | + | // only if the source branch still points to it; failed_precondition (branch | |||
| 599 | + | // moved) otherwise. | |||
| 600 | + | string head_id = 4; | |||
| 594 | } | 601 | } | ||
| 595 | 602 | ||||
| 596 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | 603 | // EnableAutoMergeResponse holds the merge request with auto-merge enabled. | ||