Bug in file creation through API in the /projects/:id/repository/files/:file_path endpoint
Summary
When creating a file through the API, a file gets created instead of a directory if the file and directory have the same name. Example:
- For the file_path:
folder-1%2Ffilename%2Ffolder-2%2Ffilename
, the file structure created should befolder-1/filename/folder-2/filename
, but instead this is the file structure created:folder-1/filename
This was tested on a self-managed instance (version 16.7.2) and gitlab.com as well.
Steps to reproduce
- Create an access token with API, read and write repository permissions
- Create a test project
- Attempt to create a file in the directory
folder-1/filename/folder-2/filename
with the API endpoint:/projects/:id/repository/files/:file_path endpoint
What is the current bug behavior?
For the file_path: folder-1%2Ffilename%2Ffolder-2%2Ffilename
, this is the file structure created: folder-1/filename
What is the expected correct behavior?
For the file_path: folder-1%2Ffilename%2Ffolder-2%2Ffilename
, the file structure created should be folder-1/filename/folder-2/filename