Commit 5f16687805b4daa98f7227849d064345e68210d2
1 parent
55779b00
Exists in
master
and in
4 other branches
Update arguments for Gitlab::Satellite::EditFileAction#initialize
Showing
2 changed files
with
7 additions
and
7 deletions
Show diff stats
app/controllers/tree_controller.rb
| @@ -26,9 +26,8 @@ class TreeController < ProjectResourceController | @@ -26,9 +26,8 @@ class TreeController < ProjectResourceController | ||
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | def update | 28 | def update |
| 29 | - file_editor = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref) | 29 | + file_editor = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref, @path) |
| 30 | update_status = file_editor.update( | 30 | update_status = file_editor.update( |
| 31 | - @path, | ||
| 32 | params[:content], | 31 | params[:content], |
| 33 | params[:commit_message], | 32 | params[:commit_message], |
| 34 | params[:last_commit] | 33 | params[:last_commit] |
lib/gitlab/satellite/edit_file_action.rb
| @@ -5,15 +5,16 @@ module Gitlab | @@ -5,15 +5,16 @@ module Gitlab | ||
| 5 | # It gives you ability to make changes to files | 5 | # It gives you ability to make changes to files |
| 6 | # & commit this changes from GitLab UI. | 6 | # & commit this changes from GitLab UI. |
| 7 | class EditFileAction < Action | 7 | class EditFileAction < Action |
| 8 | - attr_accessor :ref | 8 | + attr_accessor :path, :ref |
| 9 | 9 | ||
| 10 | - def initialize(user, project, ref) | 10 | + def initialize(user, project, ref, path) |
| 11 | super user, project | 11 | super user, project |
| 12 | + @path = path | ||
| 12 | @ref = ref | 13 | @ref = ref |
| 13 | end | 14 | end |
| 14 | 15 | ||
| 15 | - def update(path, content, commit_message, last_commit) | ||
| 16 | - return false unless can_edit?(path, last_commit) | 16 | + def update(content, commit_message, last_commit) |
| 17 | + return false unless can_edit?(last_commit) | ||
| 17 | 18 | ||
| 18 | in_locked_and_timed_satellite do |repo| | 19 | in_locked_and_timed_satellite do |repo| |
| 19 | prepare_satellite!(repo) | 20 | prepare_satellite!(repo) |
| @@ -34,7 +35,7 @@ module Gitlab | @@ -34,7 +35,7 @@ module Gitlab | ||
| 34 | 35 | ||
| 35 | protected | 36 | protected |
| 36 | 37 | ||
| 37 | - def can_edit?(path, last_commit) | 38 | + def can_edit?(last_commit) |
| 38 | current_last_commit = @project.last_commit_for(ref, path).sha | 39 | current_last_commit = @project.last_commit_for(ref, path).sha |
| 39 | last_commit == current_last_commit | 40 | last_commit == current_last_commit |
| 40 | end | 41 | end |