From 11d5ad2f17ed487ac10414c16480a23cedf60d3c Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 6 Aug 2014 14:27:22 +0200 Subject: [PATCH 1/3] Make file edit error message less specific The truth is that at the point where there error message is written we can only guess what went wrong. --- app/services/files/update_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index c631f28749..cbd441122d 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -33,7 +33,7 @@ module Files if created_successfully success else - error("Your changes could not be committed, because the file has been changed") + error("Your changes could not be committed. Maybe the file changed, or there was nothing to commit?") end end end From aa5e663f85cd7c29910c37ab9716317961c31e91 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 6 Aug 2014 14:28:22 +0200 Subject: [PATCH 2/3] List API file edit failure conditions in docs --- doc/api/repository_files.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/api/repository_files.md b/doc/api/repository_files.md index ae56b04b6c..e21e5aa8d7 100644 --- a/doc/api/repository_files.md +++ b/doc/api/repository_files.md @@ -80,6 +80,13 @@ Parameters: - `content` (required) - New file content - `commit_message` (required) - Commit message +If the commit fails for any reason we return a 400 error with a non-specific +error message. Possible causes for a failed commit include: +- the `file_path` contained `/../` (attempted directory traversal); +- the new file contents were identical to the current file contents, i.e. the + user tried to make an empty commit; +- the branch was updated by a Git push while the file edit was in progress. + ## Delete existing file in repository ``` From 43f560b17461d035bb5b9cb18a69f68512465453 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Wed, 6 Aug 2014 17:44:57 +0200 Subject: [PATCH 3/3] Add comments. --- app/services/files/update_service.rb | 2 +- doc/api/repository_files.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index cbd441122d..a0f40154db 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -33,7 +33,7 @@ module Files if created_successfully success else - error("Your changes could not be committed. Maybe the file changed, or there was nothing to commit?") + error("Your changes could not be committed. Maybe the file was changed by another process or there was nothing to commit?") end end end diff --git a/doc/api/repository_files.md b/doc/api/repository_files.md index e21e5aa8d7..b53d60bcee 100644 --- a/doc/api/repository_files.md +++ b/doc/api/repository_files.md @@ -87,6 +87,8 @@ error message. Possible causes for a failed commit include: user tried to make an empty commit; - the branch was updated by a Git push while the file edit was in progress. +Currently gitlab-shell has a boolean return code, preventing GitLab from specifying the error. + ## Delete existing file in repository ```