BigW Consortium Gitlab

Commit 727d229e by Dmitriy Zaporozhets

Fix edit files since we use Gitlab::Git::Blob for files

parent 921151d0
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment