diff options
author | randx <dmitriy.zaporozhets@gmail.com> | 2012-06-28 12:51:50 +0300 |
---|---|---|
committer | randx <dmitriy.zaporozhets@gmail.com> | 2012-06-28 12:51:50 +0300 |
commit | 335f9d64105fc887e74b22922da58b2edb1bc809 (patch) | |
tree | 0a5a8137533a647b7f380237bb891b347f80838f | |
parent | df6b587f3458a55ca21f687fde0272a103b273cd (diff) | |
download | gitlab-ce-335f9d64105fc887e74b22922da58b2edb1bc809.tar.gz |
New Feature: Diff patch file export for commit
-rw-r--r-- | app/controllers/commits_controller.rb | 11 | ||||
-rw-r--r-- | app/models/commit.rb | 1 | ||||
-rw-r--r-- | app/views/commits/_commit_box.html.haml | 13 | ||||
-rw-r--r-- | config/routes.rb | 4 |
4 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index bbf5a672d7f..25e980e017b 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -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 diff --git a/app/models/commit.rb b/app/models/commit.rb index 09635d0e21c..800ad19b9f1 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -19,6 +19,7 @@ class Commit :diffs, :tree, :id, + :to_patch, :to => :commit diff --git a/app/views/commits/_commit_box.html.haml b/app/views/commits/_commit_box.html.haml index c821c260f1b..2097d87ca1c 100644 --- a/app/views/commits/_commit_box.html.haml +++ b/app/views/commits/_commit_box.html.haml @@ -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 + + = link_to patch_project_commit_path(@project, @commit.id), :class => "btn small" do + %i.icon-download-alt + Get Patch + %h3.commit-title = commit_msg_with_link_to_issues(@project, @commit.title) - if @commit.description.present? diff --git a/config/routes.rb b/config/routes.rb index d1dd03ab985..67e4aedd030 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 |