`Repository#merge` should reset `in_progress_merge_commit_sha` when error is encountered
The second call to the Gitaly UserMergeBranch
RPC method can raise an exception. Currently, if this were to happen, the merge request's in_progress_merge_commit_sha
attribute would be set to a commit SHA that doesn't exist. We're unable to use a transaction block to roll this back (see #28171 (comment 215742217) and #33943 (closed)) so instead we should rescue from the errors that can be thrown, set the in_progress_merge_commit_sha
to nil
and then re-raise the error.
Original description
The second call to the Gitaly `UserMergeBranch` RPC method can raise an exception. Currently, if this were to happen, the merge request's `in_progress_merge_commit_sha` attribute would be set to a commit SHA that doesn't exist. `Repository#merge` should use a transaction block in order to rollback the setting of this attribute if any error occurs.Edited by Luke Duncalfe