Commit 3574826920eb958c5e59e86bb79b0773c187abfb
1 parent
169f16fb
Exists in
master
and in
4 other branches
Use Commits#show instead of Commits#index
Takes tree-ish + path as ID
Showing
9 changed files
with
69 additions
and
95 deletions
Show diff stats
app/controllers/commits_controller.rb
@@ -4,18 +4,19 @@ class CommitsController < ApplicationController | @@ -4,18 +4,19 @@ class CommitsController < ApplicationController | ||
4 | before_filter :project | 4 | before_filter :project |
5 | layout "project" | 5 | layout "project" |
6 | 6 | ||
7 | + include ExtractsPath | ||
8 | + | ||
7 | # Authorize | 9 | # Authorize |
8 | before_filter :add_project_abilities | 10 | before_filter :add_project_abilities |
9 | before_filter :authorize_read_project! | 11 | before_filter :authorize_read_project! |
10 | before_filter :authorize_code_access! | 12 | before_filter :authorize_code_access! |
11 | before_filter :require_non_empty_project | 13 | before_filter :require_non_empty_project |
12 | - before_filter :load_refs, only: :index # load @branch, @tag & @ref | ||
13 | 14 | ||
14 | - def index | ||
15 | - @repo = project.repo | 15 | + def show |
16 | + @repo = @project.repo | ||
16 | @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) | 17 | @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) |
17 | 18 | ||
18 | - @commits = @project.commits(@ref, params[:path], @limit, @offset) | 19 | + @commits = @project.commits(@ref, @path, @limit, @offset) |
19 | @commits = CommitDecorator.decorate(@commits) | 20 | @commits = CommitDecorator.decorate(@commits) |
20 | 21 | ||
21 | respond_to do |format| | 22 | respond_to do |format| |
@@ -25,26 +26,6 @@ class CommitsController < ApplicationController | @@ -25,26 +26,6 @@ class CommitsController < ApplicationController | ||
25 | end | 26 | end |
26 | end | 27 | end |
27 | 28 | ||
28 | - # def show | ||
29 | - # result = CommitLoad.new(project, current_user, params).execute | ||
30 | - | ||
31 | - # @commit = result[:commit] | ||
32 | - | ||
33 | - # if @commit | ||
34 | - # @suppress_diff = result[:suppress_diff] | ||
35 | - # @note = result[:note] | ||
36 | - # @line_notes = result[:line_notes] | ||
37 | - # @notes_count = result[:notes_count] | ||
38 | - # @comments_allowed = true | ||
39 | - # else | ||
40 | - # return git_not_found! | ||
41 | - # end | ||
42 | - | ||
43 | - # if result[:status] == :huge_commit | ||
44 | - # render "huge_commit" and return | ||
45 | - # end | ||
46 | - # end | ||
47 | - | ||
48 | def patch | 29 | def patch |
49 | @commit = project.commit(params[:id]) | 30 | @commit = project.commit(params[:id]) |
50 | 31 | ||
@@ -55,11 +36,4 @@ class CommitsController < ApplicationController | @@ -55,11 +36,4 @@ class CommitsController < ApplicationController | ||
55 | filename: "#{@commit.id}.patch" | 36 | filename: "#{@commit.id}.patch" |
56 | ) | 37 | ) |
57 | end | 38 | end |
58 | - | ||
59 | - protected | ||
60 | - | ||
61 | - def load_refs | ||
62 | - @ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence | ||
63 | - @ref ||= @ref || @project.try(:default_branch) || 'master' | ||
64 | - end | ||
65 | end | 39 | end |
app/views/commits/index.atom.builder
@@ -1,23 +0,0 @@ | @@ -1,23 +0,0 @@ | ||
1 | -xml.instruct! | ||
2 | -xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do | ||
3 | - xml.title "Recent commits to #{@project.name}:#{@ref}" | ||
4 | - xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml" | ||
5 | - xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html" | ||
6 | - xml.id project_commits_url(@project) | ||
7 | - xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? | ||
8 | - | ||
9 | - @commits.each do |commit| | ||
10 | - xml.entry do | ||
11 | - xml.id project_commit_url(@project, :id => commit.id) | ||
12 | - xml.link :href => project_commit_url(@project, :id => commit.id) | ||
13 | - xml.title truncate(commit.title, :length => 80) | ||
14 | - xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") | ||
15 | - xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) | ||
16 | - xml.author do |author| | ||
17 | - xml.name commit.author_name | ||
18 | - xml.email commit.author_email | ||
19 | - end | ||
20 | - xml.summary gfm(commit.description) | ||
21 | - end | ||
22 | - end | ||
23 | -end |
app/views/commits/index.html.haml
@@ -1,24 +0,0 @@ | @@ -1,24 +0,0 @@ | ||
1 | -= render "head" | ||
2 | - | ||
3 | -- if params[:path] | ||
4 | - %ul.breadcrumb | ||
5 | - %li | ||
6 | - %span.arrow | ||
7 | - = link_to project_commits_path(@project) do | ||
8 | - = @project.name | ||
9 | - %span.divider | ||
10 | - \/ | ||
11 | - %li | ||
12 | - %a{href: "#"}= params[:path].split("/").join(" / ") | ||
13 | - | ||
14 | -%div{id: dom_id(@project)} | ||
15 | - #commits_list= render "commits" | ||
16 | -.clear | ||
17 | -.loading{ style: "display:none;"} | ||
18 | - | ||
19 | -- if @commits.count == @limit | ||
20 | - :javascript | ||
21 | - $(function(){ | ||
22 | - CommitsList.init("#{@ref}", #{@limit}); | ||
23 | - }); | ||
24 | - |
app/views/commits/index.js.haml
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +xml.instruct! | ||
2 | +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do | ||
3 | + xml.title "Recent commits to #{@project.name}:#{@ref}" | ||
4 | + xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml" | ||
5 | + xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html" | ||
6 | + xml.id project_commits_url(@project) | ||
7 | + xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? | ||
8 | + | ||
9 | + @commits.each do |commit| | ||
10 | + xml.entry do | ||
11 | + xml.id project_commit_url(@project, :id => commit.id) | ||
12 | + xml.link :href => project_commit_url(@project, :id => commit.id) | ||
13 | + xml.title truncate(commit.title, :length => 80) | ||
14 | + xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") | ||
15 | + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email) | ||
16 | + xml.author do |author| | ||
17 | + xml.name commit.author_name | ||
18 | + xml.email commit.author_email | ||
19 | + end | ||
20 | + xml.summary gfm(commit.description) | ||
21 | + end | ||
22 | + end | ||
23 | +end |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | += render "head" | ||
2 | + | ||
3 | +- if params[:path] | ||
4 | + %ul.breadcrumb | ||
5 | + %li | ||
6 | + %span.arrow | ||
7 | + = link_to project_commits_path(@project) do | ||
8 | + = @project.name | ||
9 | + %span.divider | ||
10 | + \/ | ||
11 | + %li | ||
12 | + %a{href: "#"}= params[:path].split("/").join(" / ") | ||
13 | + | ||
14 | +%div{id: dom_id(@project)} | ||
15 | + #commits_list= render "commits" | ||
16 | +.clear | ||
17 | +.loading{ style: "display:none;"} | ||
18 | + | ||
19 | +- if @commits.count == @limit | ||
20 | + :javascript | ||
21 | + $(function(){ | ||
22 | + CommitsList.init("#{@ref}", #{@limit}); | ||
23 | + }); | ||
24 | + |
app/views/layouts/_project_menu.html.haml
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | = link_to project_tree_path(@project, @project.root_ref) do | 8 | = link_to project_tree_path(@project, @project.root_ref) do |
9 | Files | 9 | Files |
10 | %li{class: commit_tab_class} | 10 | %li{class: commit_tab_class} |
11 | - = link_to "Commits", project_commits_path(@project) | 11 | + = link_to "Commits", project_history_path(@project, @project.root_ref) |
12 | 12 | ||
13 | %li{class: tab_class(:network)} | 13 | %li{class: tab_class(:network)} |
14 | = link_to "Network", graph_project_path(@project) | 14 | = link_to "Network", graph_project_path(@project) |
config/routes.rb
@@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do | @@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do | ||
159 | end | 159 | end |
160 | end | 160 | end |
161 | 161 | ||
162 | - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} | 162 | + # XXX: WIP |
163 | + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} | ||
164 | + resources :commits, only: [:show], constraints: {id: /.+/}, as: 'history' | ||
165 | + resources :blame, only: [:show], constraints: {id: /.+/} | ||
166 | + resources :blob, only: [:show], constraints: {id: /.+/} | ||
167 | + # resources :raw, only: [:show], constraints: {id: /.+/} | ||
168 | + resources :tree, only: [:show], constraints: {id: /.+/} | ||
169 | + match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} | ||
163 | 170 | ||
164 | - resources :commits, only: [:index, :show] do | ||
165 | - member do | ||
166 | - get :patch | ||
167 | - end | ||
168 | - end | 171 | + # resources :commits, only: [:show], as: 'history' do |
172 | + # member do | ||
173 | + # get :patch | ||
174 | + # end | ||
175 | + # end | ||
169 | 176 | ||
170 | resources :team, controller: 'team_members', only: [:index] | 177 | resources :team, controller: 'team_members', only: [:index] |
171 | resources :team_members | 178 | resources :team_members |
@@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do | @@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do | ||
184 | post :preview | 191 | post :preview |
185 | end | 192 | end |
186 | end | 193 | end |
187 | - | ||
188 | - # XXX: WIP | ||
189 | - resources :blame, only: [:show], constraints: {id: /.+/} | ||
190 | - resources :blob, only: [:show], constraints: {id: /.+/} | ||
191 | - # resources :raw, only: [:show], constraints: {id: /.+/} | ||
192 | - resources :tree, only: [:show], constraints: {id: /.+/} | ||
193 | - match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} | ||
194 | end | 194 | end |
195 | 195 | ||
196 | root to: "dashboard#index" | 196 | root to: "dashboard#index" |