2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-05-02 10:18:07 +01:00
|
|
|
class Projects::Git::BlobsController < Projects::Git::BaseController
|
2012-07-17 09:02:56 +01:00
|
|
|
before_filter :set_blob
|
|
|
|
before_filter lambda {authorize! :write, @project}, :only => [:edit, :update]
|
2011-03-10 12:39:24 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2012-02-08 17:51:30 +00:00
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2012-07-17 09:02:56 +01:00
|
|
|
if @project.update_file(params[:path], params[:content].gsub("\r", ''),
|
|
|
|
:message => params[:message].gsub("\r", ''), :actor => current_user, :head => @treeish)
|
2012-03-21 19:55:14 +00:00
|
|
|
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path])
|
2012-02-09 00:26:23 +00:00
|
|
|
else
|
2012-03-21 19:55:14 +00:00
|
|
|
flash[:notice] = t("flash.blob.updating_error", :name => params[:path])
|
2012-02-09 00:26:23 +00:00
|
|
|
end
|
2012-02-08 17:51:30 +00:00
|
|
|
redirect_to :action => :show
|
|
|
|
end
|
|
|
|
|
2011-03-10 12:39:24 +00:00
|
|
|
def blame
|
2012-07-17 09:02:56 +01:00
|
|
|
@blame = Grit::Blob.blame(@project.repo, @commit.id, @path)
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def raw
|
2012-07-17 09:02:56 +01:00
|
|
|
send_data @blob.data, :type => @blob.content_type, :disposition => @blob.disposition
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
2012-02-22 22:11:55 +00:00
|
|
|
|
2012-07-17 09:02:56 +01:00
|
|
|
def set_blob
|
|
|
|
@blob = @tree / @path or raise Grit::NoSuchPathError
|
|
|
|
@commit = @project.repo.log(@treeish, @path, :max_count => 1).first
|
2012-03-21 19:55:14 +00:00
|
|
|
end
|
2012-01-20 18:31:01 +00:00
|
|
|
end
|