Commit 99d39133 authored by Robert Speicher's avatar Robert Speicher

Add a "patch" MIME type, and render it like a normal view in Commit#show

parent c058e390
...@@ -15,19 +15,22 @@ class CommitController < ApplicationController ...@@ -15,19 +15,22 @@ class CommitController < ApplicationController
result = CommitLoad.new(project, current_user, params).execute result = CommitLoad.new(project, current_user, params).execute
@commit = result[:commit] @commit = result[:commit]
git_not_found! unless @commit
if @commit @suppress_diff = result[:suppress_diff]
@suppress_diff = result[:suppress_diff] @note = result[:note]
@note = result[:note] @line_notes = result[:line_notes]
@line_notes = result[:line_notes] @notes_count = result[:notes_count]
@notes_count = result[:notes_count] @comments_allowed = true
@comments_allowed = true
else respond_to do |format|
return git_not_found! format.html do
end if result[:status] == :huge_commit
render "huge_commit" and return
end
end
if result[:status] == :huge_commit format.patch
render "huge_commit" and return
end end
end end
end end
...@@ -25,15 +25,4 @@ class CommitsController < ApplicationController ...@@ -25,15 +25,4 @@ class CommitsController < ApplicationController
format.atom { render layout: false } format.atom { render layout: false }
end end
end end
def patch
@commit = project.commit(params[:id])
send_data(
@commit.to_patch,
type: "text/plain",
disposition: 'attachment',
filename: "#{@commit.id}.patch"
)
end
end end
<%= @commit.to_patch %>
...@@ -3,3 +3,5 @@ ...@@ -3,3 +3,5 @@
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf # Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone # Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias 'text/plain', :patch
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