API Sample Fix for File Operations
Summary
The example responses for the "create", "update", and "delete" operations on a file via the API do not match the actual results.
Steps to reproduce
Issue API requests to create, update, and delete a file.
Actual behavior
(Formatting aside) The expected result is similar to the following:
array(2) {
["file_path"]=>
string(12) "testfile.txt"
["branch_name"]=>
string(6) "master"
}
Documented behavior
The documentation has the following content (Note file_name
instead of file_path
) at https://gitlab.com/help/api/repository_files.md:
{
"file_name": "app/project.rb",
"branch_name": "master"
}
Relevant logs and/or screenshots
I created a simple PHP script to perform the operations in question. The output I received is:
Create File
array(2) {
["file_path"]=>
string(12) "testfile.txt"
["branch_name"]=>
string(6) "master"
}
Update File
array(2) {
["file_path"]=>
string(12) "testfile.txt"
["branch_name"]=>
string(6) "master"
}
Delete File
array(2) {
["file_path"]=>
string(12) "testfile.txt"
["branch_name"]=>
string(6) "master"
}
For comparison, following is a log of the 3 operations from the git repository, showing the 3 operations actually worked:
commit 7371015a50b0659a5488db09a47cf89a32387bea
Author: Rick G <..@gmail.com>
Date: Fri Feb 3 15:08:25 2017 +0000
Test delete file via API
testfile.txt | 1 -
1 file changed, 1 deletion(-)
commit 803099b0817ce36b9ab2c7d986dcdf6356404885
Author: Rick G <..@gmail.com>
Date: Fri Feb 3 15:08:21 2017 +0000
Test edit file via API
testfile.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 3c49fcaa94fd5d554261a1332d175e9cd3b82b53
Author: Rick G <..@gmail.com>
Date: Fri Feb 3 15:08:17 2017 +0000
Test create file via API
testfile.txt | 1 +
1 file changed, 1 insertion(+)
Output of checks
This was just executed now on gitlab.com
Possible fixes
The file in question is at https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/api/repository_files.md
A merge request is forthcoming.