• Stan Hu's avatar
    Improve merge error when pre-receive hooks fail in fast-forward merge · 7083ab22
    Stan Hu authored
    When fast-forward merge is enabled, merges might fail due to a failed
    pre-receive check (e.g. due to file locks, commit message push rules,
    etc.) but the UI would only display:
    
    ```
    Merge failed: pre-receive hook failed. Please try again.
    ```
    
    While the raw message was logged in Sentry and in `exceptions_json.log`,
    this kept users in the dark.
    
    Gitaly prefaces the error response status from the `/internal/allowed`
    API call with `GitLab:`, so we can use this to display the error to the
    user. We now only fallback to a default if we do not have anything to
    show. Now, users see a more informative message, such as:
    
    ```
    Merge failed: Commit message does not follow the pattern
    'MERGEME'. Please try again.
    ```
    
    Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/246816
    7083ab22
pre_receive_error_spec.rb 1.28 KB