Commit b389247c029b21f5e85abb5896d2cf22230c9cb1

Authored by Robert Speicher
1 parent a21abce9

Use Commit#show instead of Commits#show to view a single commit

Commits#show (plural) is going to be for showing commit history on a
specific path.
app/controllers/commits_controller.rb
@@ -26,25 +26,25 @@ class CommitsController < ApplicationController @@ -26,25 +26,25 @@ class CommitsController < ApplicationController
26 end 26 end
27 end 27 end
28 28
29 - def show  
30 - result = CommitLoad.new(project, current_user, params).execute  
31 -  
32 - @commit = result[:commit]  
33 -  
34 - if @commit  
35 - @suppress_diff = result[:suppress_diff]  
36 - @note = result[:note]  
37 - @line_notes = result[:line_notes]  
38 - @notes_count = result[:notes_count]  
39 - @comments_allowed = true  
40 - else  
41 - return git_not_found!  
42 - end  
43 -  
44 - if result[:status] == :huge_commit  
45 - render "huge_commit" and return  
46 - end  
47 - end 29 + # def show
  30 + # result = CommitLoad.new(project, current_user, params).execute
  31 +
  32 + # @commit = result[:commit]
  33 +
  34 + # if @commit
  35 + # @suppress_diff = result[:suppress_diff]
  36 + # @note = result[:note]
  37 + # @line_notes = result[:line_notes]
  38 + # @notes_count = result[:notes_count]
  39 + # @comments_allowed = true
  40 + # else
  41 + # return git_not_found!
  42 + # end
  43 +
  44 + # if result[:status] == :huge_commit
  45 + # render "huge_commit" and return
  46 + # end
  47 + # end
48 48
49 def compare 49 def compare
50 result = Commit.compare(project, params[:from], params[:to]) 50 result = Commit.compare(project, params[:from], params[:to])
app/roles/static_model.rb
@@ -25,6 +25,10 @@ module StaticModel @@ -25,6 +25,10 @@ module StaticModel
25 id 25 id
26 end 26 end
27 27
  28 + def new_record?
  29 + false
  30 + end
  31 +
28 def persisted? 32 def persisted?
29 false 33 false
30 end 34 end
app/views/commit/show.html.haml 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 += render "commits/commit_box"
  2 += render "commits/diffs", diffs: @commit.diffs
  3 += render "notes/notes_with_form", tid: @commit.id, tt: "commit"
  4 += render "notes/per_line_form"
  5 +
  6 +
  7 +:javascript
  8 + $(function(){
  9 + PerLineNotes.init();
  10 + });
app/views/commits/_commit.html.haml
1 %li.commit 1 %li.commit
2 .browse_code_link_holder 2 .browse_code_link_holder
3 %p 3 %p
4 - %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), class: "right" 4 + %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit), class: "right"
5 %p 5 %p
6 - = link_to commit.short_id(8), project_commit_path(@project, id: commit.id), class: "commit_short_id" 6 + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id"
7 %strong.commit-author-name= commit.author_name 7 %strong.commit-author-name= commit.author_name
8 %span.dash – 8 %span.dash –
9 = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 9 = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16
10 - = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, id: commit.id), class: "row_title" 10 + = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, commit.id), class: "row_title"
11 11
12 %span.committed_ago 12 %span.committed_ago
13 = time_ago_in_words(commit.committed_date) 13 = time_ago_in_words(commit.committed_date)
14 ago 14 ago
15   15  
16 -  
app/views/commits/show.html.haml
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -= render "commits/commit_box"  
2 -= render "commits/diffs", diffs: @commit.diffs  
3 -= render "notes/notes_with_form", tid: @commit.id, tt: "commit"  
4 -= render "notes/per_line_form"  
5 -  
6 -  
7 -:javascript  
8 - $(function(){  
9 - PerLineNotes.init();  
10 - });  
app/views/events/_commit.html.haml
1 - commit = CommitDecorator.decorate(commit) 1 - commit = CommitDecorator.decorate(commit)
2 %li.commit 2 %li.commit
3 %p 3 %p
4 - = link_to commit.short_id(8), project_commit_path(project, id: commit.id), class: "commit_short_id" 4 + = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
5 %span= commit.author_name 5 %span= commit.author_name
6 – 6 –
7 = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 7 = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16
app/views/refs/blame.html.haml
@@ -32,8 +32,8 @@ @@ -32,8 +32,8 @@
32 = commit.author_name 32 = commit.author_name
33 %td.blame_commit 33 %td.blame_commit
34   34  
35 - %code= link_to commit.short_id, project_commit_path(@project, id: commit.id)  
36 - = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, id: commit.id), class: "row_title" rescue "--broken encoding" 35 + %code= link_to commit.short_id, project_commit_path(@project, commit)
  36 + = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, commit), class: "row_title" rescue "--broken encoding"
37 %td.lines 37 %td.lines
38 = preserve do 38 = preserve do
39 %pre 39 %pre
app/views/repositories/_branch.html.haml
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 - if branch.name == @project.root_ref 7 - if branch.name == @project.root_ref
8 %span.label default 8 %span.label default
9 %td 9 %td
10 - = link_to project_commit_path(@project, id: commit.id) do 10 + = link_to project_commit_path(@project, commit) do
11 %code= commit.short_id 11 %code= commit.short_id
12 12
13 = image_tag gravatar_icon(commit.author_email), class: "", width: 16 13 = image_tag gravatar_icon(commit.author_email), class: "", width: 16
lib/gitlab/markdown.rb
@@ -174,7 +174,7 @@ module Gitlab @@ -174,7 +174,7 @@ module Gitlab
174 174
175 def reference_commit(identifier) 175 def reference_commit(identifier)
176 if commit = @project.commit(identifier) 176 if commit = @project.commit(identifier)
177 - link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) 177 + link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
178 end 178 end
179 end 179 end
180 end 180 end
spec/requests/gitlab_flavored_markdown_spec.rb
@@ -49,13 +49,13 @@ describe "Gitlab Flavored Markdown" do @@ -49,13 +49,13 @@ describe "Gitlab Flavored Markdown" do
49 end 49 end
50 50
51 it "should render title in commits#show" do 51 it "should render title in commits#show" do
52 - visit project_commit_path(project, id: commit.id) 52 + visit project_commit_path(project, commit)
53 53
54 page.should have_link("##{issue.id}") 54 page.should have_link("##{issue.id}")
55 end 55 end
56 56
57 it "should render description in commits#show" do 57 it "should render description in commits#show" do
58 - visit project_commit_path(project, id: commit.id) 58 + visit project_commit_path(project, commit)
59 59
60 page.should have_link("@#{fred.name}") 60 page.should have_link("@#{fred.name}")
61 end 61 end
@@ -175,7 +175,7 @@ describe "Gitlab Flavored Markdown" do @@ -175,7 +175,7 @@ describe "Gitlab Flavored Markdown" do
175 175
176 describe "for notes" do 176 describe "for notes" do
177 it "should render in commits#show", js: true do 177 it "should render in commits#show", js: true do
178 - visit project_commit_path(project, id: commit.id) 178 + visit project_commit_path(project, commit)
179 fill_in "note_note", with: "see ##{issue.id}" 179 fill_in "note_note", with: "see ##{issue.id}"
180 click_button "Add Comment" 180 click_button "Add Comment"
181 181
spec/routing/project_routing_spec.rb
@@ -298,6 +298,14 @@ describe HooksController, "routing" do @@ -298,6 +298,14 @@ describe HooksController, "routing" do
298 end 298 end
299 end 299 end
300 300
  301 +# project_commit GET /:project_id/commit/:id(.:format) commit#show {:id=>/[[:alnum:]]{6,40}/, :project_id=>/[^\/]+/}
  302 +describe CommitController, "routing" do
  303 + it "to #show" do
  304 + get("/gitlabhq/commit/4246fb").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb')
  305 + get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
  306 + end
  307 +end
  308 +
301 # compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare 309 # compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare
302 # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch 310 # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
303 # project_commits GET /:project_id/commits(.:format) commits#index 311 # project_commits GET /:project_id/commits(.:format) commits#index
@@ -317,6 +325,7 @@ describe CommitsController, "routing" do @@ -317,6 +325,7 @@ describe CommitsController, "routing" do
317 end 325 end
318 326
319 it_behaves_like "RESTful project resources" do 327 it_behaves_like "RESTful project resources" do
  328 + let(:actions) { [:index, :show] }
320 let(:controller) { 'commits' } 329 let(:controller) { 'commits' }
321 end 330 end
322 end 331 end