Commit c0df0cd70c9036c2b3bf11f823d61a3618e6d16a
1 parent
a7ed8276
Exists in
master
and in
4 other branches
Commit header improved. finalize PR 667
Showing
6 changed files
with
97 additions
and
98 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/assets/stylesheets/sections/commits.scss
| 1 | -.commit-head { | |
| 1 | +.commit-box { | |
| 2 | 2 | @extend .main_box; |
| 3 | 3 | |
| 4 | - padding: 14px; | |
| 5 | - padding-bottom: 8px; | |
| 6 | - line-height: 24px; | |
| 4 | + .commit-head { | |
| 5 | + @extend .top_box_content; | |
| 7 | 6 | |
| 8 | - .browse-button { | |
| 9 | - @extend .btn; | |
| 10 | - @extend .btn-small; | |
| 11 | - float: right; | |
| 12 | - } | |
| 7 | + .commit-title { | |
| 8 | + line-height: 26px; | |
| 9 | + margin:0; | |
| 10 | + } | |
| 13 | 11 | |
| 14 | - .commit-title { | |
| 15 | - line-height: 26px; | |
| 16 | - } | |
| 12 | + .commit-description { | |
| 13 | + font-size: 14px; | |
| 14 | + border: none; | |
| 15 | + background-color: white; | |
| 16 | + padding-top:10px; | |
| 17 | + } | |
| 17 | 18 | |
| 18 | - .commit-description { | |
| 19 | - font-size: 14px; | |
| 20 | - padding: 0px; | |
| 21 | - padding-bottom: 4px; | |
| 22 | - border: none; | |
| 23 | - background-color: white; | |
| 19 | + .browse-button { | |
| 20 | + @extend .btn; | |
| 21 | + @extend .btn-small; | |
| 22 | + float: right; | |
| 23 | + } | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | .commit-info { |
| 27 | 27 | @extend .middle_box_content; |
| 28 | 28 | @extend .clearfix; |
| 29 | 29 | |
| 30 | - padding-bottom: 8px; | |
| 31 | - padding-top: 8px; | |
| 32 | - | |
| 33 | - margin-left: -14px; | |
| 34 | - margin-right: -14px; | |
| 35 | - margin-bottom: -8px; | |
| 30 | + .sha-block { | |
| 31 | + text-align:right; | |
| 32 | + &:first-child { | |
| 33 | + padding-bottom:6px; | |
| 34 | + } | |
| 36 | 35 | |
| 37 | - .author .name, .committer .name { | |
| 38 | - font-weight: bold; | |
| 36 | + a { | |
| 37 | + border-bottom: 1px solid #aaa; | |
| 38 | + margin-left: 9px; | |
| 39 | + } | |
| 39 | 40 | } |
| 40 | - } | |
| 41 | 41 | |
| 42 | - .sha-block { | |
| 43 | - float: right; | |
| 44 | - margin-left: 10px | |
| 45 | - } | |
| 46 | - | |
| 47 | - &.merge-commit .sha-block { | |
| 48 | - clear: right; | |
| 49 | - } | |
| 42 | + &.merge-commit .sha-block { | |
| 43 | + clear: right; | |
| 44 | + } | |
| 50 | 45 | |
| 51 | - .committer { | |
| 52 | - padding-left: 32px; | |
| 53 | - } | |
| 46 | + .committer { | |
| 47 | + padding-left: 32px; | |
| 48 | + } | |
| 54 | 49 | |
| 55 | - .avatar { | |
| 56 | - margin-right: 4px; | |
| 50 | + .avatar { | |
| 51 | + margin-right: 10px; | |
| 52 | + } | |
| 57 | 53 | } |
| 58 | -} | |
| 59 | 54 | \ No newline at end of file |
| 55 | +} | ... | ... |
app/controllers/commits_controller.rb
| ... | ... | @@ -29,6 +29,8 @@ class CommitsController < ApplicationController |
| 29 | 29 | |
| 30 | 30 | git_not_found! and return unless @commit |
| 31 | 31 | |
| 32 | + @commit = CommitDecorator.decorate(@commit) | |
| 33 | + | |
| 32 | 34 | @note = @project.build_commit_note(@commit) |
| 33 | 35 | @comments_allowed = true |
| 34 | 36 | @line_notes = project.commit_line_notes(@commit) | ... | ... |
app/decorators/commit_decorator.rb
| 1 | 1 | class CommitDecorator < ApplicationDecorator |
| 2 | 2 | decorates :commit |
| 3 | 3 | |
| 4 | + # Returns the commits title. | |
| 5 | + # | |
| 6 | + # Usually, the commit title is the first line of the commit message. | |
| 7 | + # In case this first line is longer than 80 characters, it is cut off | |
| 8 | + # after 70 characters and ellipses (`&hellp;`) are appended. | |
| 9 | + def title | |
| 10 | + title_end = safe_message.index(/\n/) | |
| 11 | + if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 12 | + safe_message[0..69] << "…".html_safe | |
| 13 | + else | |
| 14 | + safe_message.split(/\n/, 2).first | |
| 15 | + end | |
| 16 | + end | |
| 17 | + | |
| 18 | + # Returns the commits description | |
| 19 | + # | |
| 20 | + # cut off, ellipses (`&hellp;`) are prepended to the commit message. | |
| 21 | + def description | |
| 22 | + title_end = safe_message.index(/\n/) | |
| 23 | + if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 24 | + "…".html_safe << safe_message[70..-1] | |
| 25 | + else | |
| 26 | + safe_message.split(/\n/, 2)[1].try(:chomp) | |
| 27 | + end | |
| 28 | + end | |
| 29 | + | |
| 4 | 30 | def breadcrumbs |
| 5 | 31 | |
| 6 | 32 | end | ... | ... |
app/models/commit.rb
| ... | ... | @@ -106,36 +106,6 @@ class Commit |
| 106 | 106 | utf8 author.name |
| 107 | 107 | end |
| 108 | 108 | |
| 109 | - # Returns the commits title. | |
| 110 | - # | |
| 111 | - # Usually, the commit title is the first line of the commit message. | |
| 112 | - # In case this first line is longer than 80 characters, it is cut off | |
| 113 | - # after 70 characters and ellipses (`&hellp;`) are appended. | |
| 114 | - # | |
| 115 | - # @todo This might be better placed in a view helper. | |
| 116 | - def title | |
| 117 | - title_end = safe_message.index(/\n/) | |
| 118 | - if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 119 | - safe_message[0..69] << "…".html_safe | |
| 120 | - else | |
| 121 | - safe_message.split(/\n/, 2).first | |
| 122 | - end | |
| 123 | - end | |
| 124 | - | |
| 125 | - # Returns the commits description | |
| 126 | - # | |
| 127 | - # cut off, ellipses (`&hellp;`) are prepended to the commit message. | |
| 128 | - # | |
| 129 | - # @todo This might be better placed in a view helper. | |
| 130 | - def description | |
| 131 | - title_end = safe_message.index(/\n/) | |
| 132 | - if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) | |
| 133 | - "…".html_safe << safe_message[70..-1] | |
| 134 | - else | |
| 135 | - safe_message.split(/\n/, 2)[1].try(:chomp) | |
| 136 | - end | |
| 137 | - end | |
| 138 | - | |
| 139 | 109 | # Was this commit committed by a different person than the original author? |
| 140 | 110 | def different_committer? |
| 141 | 111 | author_name != committer_name || author_email != committer_email | ... | ... |
app/views/commits/show.html.haml
| 1 | -.commit-head{class: @commit.parents.count > 1 ? "merge-commit" : ""} | |
| 2 | - = link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button" | |
| 3 | - %h3.commit-title | |
| 4 | - = commit_msg_with_link_to_issues(@project, @commit.title) | |
| 5 | - - if @commit.description.present? | |
| 6 | - %pre.commit-description | |
| 7 | - = commit_msg_with_link_to_issues(@project, @commit.description) | |
| 1 | +.commit-box{class: @commit.parents.count > 1 ? "merge-commit" : ""} | |
| 2 | + .commit-head | |
| 3 | + = link_to "Browse Code »", tree_project_ref_path(@project, @commit.id), :class => "browse-button" | |
| 4 | + %h3.commit-title | |
| 5 | + = commit_msg_with_link_to_issues(@project, @commit.title) | |
| 6 | + - if @commit.description.present? | |
| 7 | + %pre.commit-description | |
| 8 | + = commit_msg_with_link_to_issues(@project, @commit.description) | |
| 8 | 9 | .commit-info |
| 9 | - %span.sha-block | |
| 10 | - commit | |
| 11 | - %code= @commit.id | |
| 12 | - %span.sha-block | |
| 13 | - = pluralize(@commit.parents.count, "parent") | |
| 14 | - - @commit.parents.each do |parent| | |
| 15 | - %code= link_to parent.id, project_commit_path(@project, parent) | |
| 16 | - .author | |
| 17 | - = image_tag gravatar_icon(@commit.author_email, 24), :class => "avatar", :height => 24, :width => 24 | |
| 18 | - %span.name= @commit.author_name | |
| 19 | - authored | |
| 20 | - %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} | |
| 21 | - #{time_ago_in_words(@commit.authored_date)} ago | |
| 22 | - - if @commit.different_committer? | |
| 23 | - .committer | |
| 24 | - %span.name= @commit.committer_name | |
| 25 | - committed | |
| 26 | - %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} | |
| 27 | - #{time_ago_in_words(@commit.committed_date)} ago | |
| 10 | + .row | |
| 11 | + .span4 | |
| 12 | + = image_tag gravatar_icon(@commit.author_email, 40), :class => "avatar" | |
| 13 | + .author | |
| 14 | + %strong= @commit.author_name | |
| 15 | + authored | |
| 16 | + %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} | |
| 17 | + #{time_ago_in_words(@commit.authored_date)} ago | |
| 18 | + - if @commit.different_committer? | |
| 19 | + .committer | |
| 20 | + → | |
| 21 | + %strong= @commit.committer_name | |
| 22 | + committed | |
| 23 | + %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} | |
| 24 | + #{time_ago_in_words(@commit.committed_date)} ago | |
| 25 | + .span7.right | |
| 26 | + .sha-block | |
| 27 | + %span.cgray commit | |
| 28 | + %code= @commit.id | |
| 29 | + .sha-block | |
| 30 | + %span.cgray= pluralize(@commit.parents.count, "parent") | |
| 31 | + - @commit.parents.each do |parent| | |
| 32 | + = link_to parent.id[0...10], project_commit_path(@project, parent) | |
| 28 | 33 | |
| 29 | 34 | = render "commits/diffs", :diffs => @commit.diffs |
| 30 | 35 | = render "notes/notes", :tid => @commit.id, :tt => "commit" | ... | ... |