diff options
author | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2017-06-07 23:31:06 +0000 |
---|---|---|
committer | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2017-06-07 23:31:06 +0000 |
commit | fb80347dc00657ba36576f1f23bd42fdbcf9520a (patch) | |
tree | 2642ac39cda31e29ea80defdc71e00c89ac8979e /lib/api/files.rb | |
parent | 73924cc51495f5f497114ed9f9de02f8b9c4205b (diff) | |
parent | 6eb96b2019d392d906a64108dbe83b3ce7cce758 (diff) | |
download | gitlab-ce-additional-metrics-dashboard.tar.gz |
Merge branch '28717-additional-metrics-review-branch' into 'additional-metrics-dashboard'additional-metrics-dashboard
# Conflicts:
# app/assets/stylesheets/pages/environments.scss
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r-- | lib/api/files.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb index e6ea12c5ab7..25b0968a271 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -10,7 +10,8 @@ module API file_content: attrs[:content], file_content_encoding: attrs[:encoding], author_email: attrs[:author_email], - author_name: attrs[:author_name] + author_name: attrs[:author_name], + last_commit_sha: attrs[:last_commit_id] } end @@ -46,6 +47,7 @@ module API use :simple_file_params requires :content, type: String, desc: 'File content' optional :encoding, type: String, values: %w[base64], desc: 'File encoding' + optional :last_commit_id, type: String, desc: 'Last known commit id for this file' end end @@ -111,7 +113,12 @@ module API authorize! :push_code, user_project file_params = declared_params(include_missing: false) - result = ::Files::UpdateService.new(user_project, current_user, commit_params(file_params)).execute + + begin + result = ::Files::UpdateService.new(user_project, current_user, commit_params(file_params)).execute + rescue ::Files::UpdateService::FileChangedError => e + render_api_error!(e.message, 400) + end if result[:status] == :success status(200) |