Return 409 on update file conflict and clarify last_commit_id usage
What does this MR do?
Hi, RE https://docs.gitlab.com/ee/api/repository_files.html#update-existing-file-in-repository
I found it unclear that the param to use to avoid overwriting other updates is last_commit_id
.
I clarified the doc and also return a HTTP 409 Conflict if there is a conflict.
But what I really wanted to do was also return the updated SHA, so that we don't have to make another request just to get the updated SHA.
But I'm new to Ruby and this project, I traced the response:
update_service.rb->create_commit
respository.rb -> update_file
update_file -> multi_action
multi_action -> Gitlab::Git::OperationService::BranchUpdate.from_gitaly
def self.from_gitaly(branch_update)
return if branch_update.nil?
new(
branch_update.commit_id,
branch_update.repo_created,
branch_update.branch_created
)
end
But it's not obvious to me where the response is generated, current it's:
{
"file_path": "src/locales/en.js",
"branch": "master"
}
and I want to change it to:
{
"file_path": "src/locales/en.js",
"branch": "master",
"sha": "new sha"
}
What are the relevant issue numbers?
https://gitlab.com/gitlab-org/gitlab-ce/issues/56885
Does this MR meet the acceptance criteria?
I will fill this/do it in if someone points me in the right direction of returning the new SHA
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer
Edited by Dominic