diff --git a/app/controllers/edit_tree_controller.rb b/app/controllers/edit_tree_controller.rb index aae983aa502..4322e1ee3b0 100644 --- a/app/controllers/edit_tree_controller.rb +++ b/app/controllers/edit_tree_controller.rb @@ -22,7 +22,7 @@ class EditTreeController < ProjectResourceController ) if updated_successfully - redirect_to project_tree_path(@project, @id), notice: "Your changes have been successfully commited" + redirect_to project_blob_path(@project, @id), notice: "Your changes have been successfully commited" else flash[:notice] = "Your changes could not be commited, because the file has been changed" render :edit @@ -32,8 +32,10 @@ class EditTreeController < ProjectResourceController private def edit_requirements - unless @tree.is_blob? && @tree.text? - redirect_to project_tree_path(@project, @id), notice: "You can only edit text files" + @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path) + + unless @blob.exists? && @blob.text? + redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" end allowed = if project.protected_branch? @ref diff --git a/app/views/edit_tree/show.html.haml b/app/views/edit_tree/show.html.haml index 211396ba5d2..e7bdeb39e72 100644 --- a/app/views/edit_tree/show.html.haml +++ b/app/views/edit_tree/show.html.haml @@ -4,21 +4,21 @@ .file_title %i.icon-file %span.file_name - = @tree.path + = @path %small on %strong= @ref %span.options .btn-group.tree-btn-group - = link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: "Are you sure?" + = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: "Are you sure?" .file_content.code - %pre#editor= @tree.data + %pre#editor= @blob.data .control-group.commit_message-group = label_tag 'commit_message', class: "control-label" do Commit message .controls - = text_area_tag 'commit_message', '', placeholder: "Update #{@tree.name}", required: true, rows: 3 + = text_area_tag 'commit_message', '', placeholder: "Update #{@blob.name}", required: true, rows: 3 .form-actions = hidden_field_tag 'last_commit', @last_commit = hidden_field_tag 'content', '', id: :file_content @@ -30,7 +30,7 @@ = link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-cancel", confirm: "Are you sure?" :javascript - var ace_mode = "#{@tree.language.try(:ace_mode)}"; + var ace_mode = "#{@blob.language.try(:ace_mode)}"; var editor = ace.edit("editor"); if (ace_mode) { editor.getSession().setMode('ace/mode/' + ace_mode);