summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-03 16:49:32 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-03 16:49:32 +0300
commit727d229e28012b3469760c69e028192b617b7e15 (patch)
treeefac19ade7db8f9deb7acea464531f29746f4a4b /app
parent921151d0414512df79f0724e0a52af6ab96108d1 (diff)
downloadgitlab-ce-727d229e28012b3469760c69e028192b617b7e15.tar.gz
Fix edit files since we use Gitlab::Git::Blob for files
Diffstat (limited to 'app')
-rw-r--r--app/controllers/edit_tree_controller.rb8
-rw-r--r--app/views/edit_tree/show.html.haml10
2 files changed, 10 insertions, 8 deletions
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);