[go: up one dir, main page]

Skip to content

Code changes lost when commit message violates push rules using Edit > "Edit Single File"

Summary

When editing a file directly ('Edit single file'), if a user attempts to commit changes with a message that doesn't comply with the configured push rules, the commit is rejected as expected. However, the code changes are also lost, forcing the user to re-enter their modifications. This behavior is observed in GitLab 17.3.1.

According to the customer this didn't used to happen, however I was unable to find a commit that caused the issue.

Steps to reproduce

  1. Set up a GitLab project with a pre-receive hook that enforces a specific commit message pattern.
  2. Choose a file in the repository and click on the "Edit > Edit Single File" button to open the editor.
  3. Make some changes to the file content.
  4. Instead of following the required commit message pattern, enter a commit message that doesn't match. For example: "Updated file content"
  5. Click on "Commit changes" to attempt to save your changes.
  6. Observe the error message: "13:update reference: running pre-receive hooks: GitLab: Commit message does not follow the pattern '^(...)'."
  7. Try to navigate back to the file or refresh the page.
  8. Check if the changes you made to the file content are still present or if they have been lost.

What is the current bug behavior?

Changes are lost because the page is refreshed.

What is the expected correct behavior?

The user should have the chance to fix their commit message before the page is refreshed.

Edited by Adam Mulvany