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 26 end
27 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 49 def compare
50 50 result = Commit.compare(project, params[:from], params[:to])
... ...
app/roles/static_model.rb
... ... @@ -25,6 +25,10 @@ module StaticModel
25 25 id
26 26 end
27 27  
  28 + def new_record?
  29 + false
  30 + end
  31 +
28 32 def persisted?
29 33 false
30 34 end
... ...
app/views/commit/show.html.haml 0 → 100644
... ... @@ -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 1 %li.commit
2 2 .browse_code_link_holder
3 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 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 7 %strong.commit-author-name= commit.author_name
8 8 %span.dash –
9 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 12 %span.committed_ago
13 13 = time_ago_in_words(commit.committed_date)
14 14 ago
15 15  
16   -
... ...
app/views/commits/show.html.haml
... ... @@ -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 1 - commit = CommitDecorator.decorate(commit)
2 2 %li.commit
3 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 5 %span= commit.author_name
6 6 –
7 7 = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16
... ...
app/views/refs/blame.html.haml
... ... @@ -32,8 +32,8 @@
32 32 = commit.author_name
33 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 37 %td.lines
38 38 = preserve do
39 39 %pre
... ...
app/views/repositories/_branch.html.haml
... ... @@ -7,7 +7,7 @@
7 7 - if branch.name == @project.root_ref
8 8 %span.label default
9 9 %td
10   - = link_to project_commit_path(@project, id: commit.id) do
  10 + = link_to project_commit_path(@project, commit) do
11 11 %code= commit.short_id
12 12  
13 13 = image_tag gravatar_icon(commit.author_email), class: "", width: 16
... ...
lib/gitlab/markdown.rb
... ... @@ -174,7 +174,7 @@ module Gitlab
174 174  
175 175 def reference_commit(identifier)
176 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 178 end
179 179 end
180 180 end
... ...
spec/requests/gitlab_flavored_markdown_spec.rb
... ... @@ -49,13 +49,13 @@ describe "Gitlab Flavored Markdown" do
49 49 end
50 50  
51 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 54 page.should have_link("##{issue.id}")
55 55 end
56 56  
57 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 60 page.should have_link("@#{fred.name}")
61 61 end
... ... @@ -175,7 +175,7 @@ describe "Gitlab Flavored Markdown" do
175 175  
176 176 describe "for notes" do
177 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 179 fill_in "note_note", with: "see ##{issue.id}"
180 180 click_button "Add Comment"
181 181  
... ...
spec/routing/project_routing_spec.rb
... ... @@ -298,6 +298,14 @@ describe HooksController, "routing" do
298 298 end
299 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 309 # compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare
302 310 # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
303 311 # project_commits GET /:project_id/commits(.:format) commits#index
... ... @@ -317,6 +325,7 @@ describe CommitsController, "routing" do
317 325 end
318 326  
319 327 it_behaves_like "RESTful project resources" do
  328 + let(:actions) { [:index, :show] }
320 329 let(:controller) { 'commits' }
321 330 end
322 331 end
... ...