Catch Git::CommandError in Branches::CreateService
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: - Gitaly checks if the requested branch name exists by executing a `git for-each-ref <BRANCH_NAME>` - This returns `feature/widget` because `feature` is a component of `feature/widget`. - Gitaly compares this against the requested branch name, finds they don't match, and returns `ErrReferenceAmbiguous` to Rails. This commit catches the `Gitlab::Git::CommandError` and advises the user which branch failed to be created. Changelog: fixed
Showing
Please register or sign in to comment