gitlab-org--gitlab-foss/app/controllers/projects/edit_tree_controller.rb
Dmitriy Zaporozhets 160bd862be
Refactoring for EditTree and NewTree controllers and contexts
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2013-11-05 12:21:11 +02:00

26 lines
653 B
Ruby

class Projects::EditTreeController < Projects::BaseTreeController
before_filter :require_branch_head
before_filter :blob
def show
@last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha
end
def update
result = Files::UpdateContext.new(@project, current_user, params, @ref, @path).execute
if result[:status] == :success
flash[:notice] = "Your changes have been successfully commited"
redirect_to project_blob_path(@project, @id)
else
flash[:alert] = result[:error]
render :show
end
end
private
def blob
@blob ||= @repository.blob_at(@commit.id, @path)
end
end