Skip to content

fix: Handle commit errors gracefully

Enrique Alcántara requested to merge 389479-handle-commit-errors into main

This Merge Request improves the message that we provide to the user when a commit fails by handling several error types individually.

Screenshots

Error type Message
User session expired session_expired
Push rule violation push_rule
Branch already exists branch_already_exists
File has changed file_changed
Unauthorized to push to branch unauthorized_to_push_to_branch

How to reproduce

There are (of course) different reproduction steps for every error:

Session expired

  1. Uncomment the following snippet !151 (diffs)
  2. Change a file and commit as usual. That code snippet will delete the authorization token after three seconds which reproduces the session expired error.

Push rule violation

  1. Create a push rule in your test project in Project Settings -> Repository -> Push rules. For example: https://gdk.test:3443/gitlab-org/gitlab-shell/-/settings/repository#js-push-rules
  2. Create a commit that violates the push rule in the Web IDE.

Branch already exists

  1. Create a new branch with a name already taken by another branch.

File has changed

  1. Open the Web IDE in two tabs.
  2. Open the same branch in both tabs.
  3. Change a file in tab no. 1 and commit.
  4. Change the same file in tab no. 2 and commit.

Unauthorized to push to that branch

  1. Try committing to a branch that you can’t push to like main or master.
Edited by Enrique Alcántara

Merge request reports