New Feature: Diff patch file export for commit

This commit is contained in:
randx 2012-06-28 12:51:50 +03:00
parent df6b587f34
commit 335f9d6410
4 changed files with 28 additions and 1 deletions

View file

@ -64,4 +64,15 @@ class CommitsController < ApplicationController
@commit = Commit.new(older)
end
end
def patch
@commit = project.commit(params[:id])
send_data(
@commit.to_patch,
:type => "text/plain",
:disposition => 'attachment',
:filename => (@commit.id.to_s + ".patch")
)
end
end

View file

@ -19,6 +19,7 @@ class Commit
:diffs,
:tree,
:id,
:to_patch,
:to => :commit

View file

@ -1,6 +1,17 @@
.commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""}
.commit-head
= link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button"
.right
= link_to tree_project_ref_path(@project, @commit.id), :class => "browse-button primary" do
%strong Browse Code »
- if @notes_count > 0
%span.btn.disabled
%i.icon-comment
= @notes_count
&nbsp;
= link_to patch_project_commit_path(@project, @commit.id), :class => "btn small" do
%i.icon-download-alt
Get Patch
&nbsp;
%h3.commit-title
= commit_msg_with_link_to_issues(@project, @commit.title)
- if @commit.description.present?

View file

@ -154,6 +154,10 @@ Gitlab::Application.routes.draw do
collection do
get :compare
end
member do
get :patch
end
end
resources :team_members
resources :milestones