Optimize creation of commit API by using Repository#commit instead of Repository#commits

Repository#commits is expensive because it has to use Rugged to walk the Git
tree as opposed to doing a direct ref lookup.

Improves performance in #34533
This commit is contained in:
Stan Hu 2017-07-03 15:46:52 -07:00
parent b5b4054d58
commit 2a9c2fec4e
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,4 @@
---
title: Optimize creation of commit API by using Repository#commit instead of Repository#commits
merge_request:
author:

View file

@ -67,7 +67,7 @@ module API
result = ::Files::MultiService.new(user_project, current_user, attrs).execute
if result[:status] == :success
commit_detail = user_project.repository.commits(result[:result], limit: 1).first
commit_detail = user_project.repository.commit(result[:result])
present commit_detail, with: Entities::RepoCommitDetail
else
render_api_error!(result[:message], 400)