Skip to content

Catch Git::CommandError in Branches::CreateService

Will Chandler (ex-GitLab) requested to merge wc-catch-cmderr-branch into master

What does this MR do?

When creating a branch, one source of failure is when the new branch name matches a component of an existing branches name. For example, feature and feature/widget. In this scenario the Gitaly UserCreateBranch RPC returns a Gitlab::Git::CommandError, which is uncaught and results in a 500 error.

The specific reason for the error is the following:

Also, in the inverse situation, e.g. feature exists and the user is creating feature/widget, our current Invalid reference name error gives no indication of what branch was being created.

This is a particular problem for pull mirroring, where the SHA1 of the source branch is used rather than a human-readable name. This requires the user to copy down the SHA and go to the source repo to attempt to understand which branch is causing the failure.

This MR catches Gitlab::Git::CommandError in this scenario and also expands the general error message to mention the branch being created.

Screenshots

  • When creating an invalid branch in the UI:

Screen_Shot_2021-06-23_at_2.37.36_PM

  • Mirroring failure:

Screen_Shot_2021-06-23_at_2.40.52_PM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Will Chandler (ex-GitLab)

Merge request reports

Loading