Commit a7ed8276d7d9448f454f7bbfe8b4a3fb305ae446
Exists in
master
and in
4 other branches
Merge branch 'nicer_commit_headers' of https://github.com/arthurschreiber/gitlab…
…hq into arthurschreiber-nicer_commit_headers
Showing
4 changed files
with
126 additions
and
23 deletions
Show diff stats
app/assets/stylesheets/main.scss
| @@ -94,7 +94,12 @@ $hover: #FDF5D9; | @@ -94,7 +94,12 @@ $hover: #FDF5D9; | ||
| 94 | @import "common.scss"; | 94 | @import "common.scss"; |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| 97 | - * This scss file redefine chozen selectbox styles for | 97 | + * Styles related to displaying commits |
| 98 | + */ | ||
| 99 | +@import "sections/commits.scss"; | ||
| 100 | + | ||
| 101 | +/** | ||
| 102 | + * This scss file redefine chozen selectbox styles for | ||
| 98 | * project Branch/Tag select element | 103 | * project Branch/Tag select element |
| 99 | */ | 104 | */ |
| 100 | @import "ref_select.scss"; | 105 | @import "ref_select.scss"; |
| @@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
| 1 | +.commit-head { | ||
| 2 | + @extend .main_box; | ||
| 3 | + | ||
| 4 | + padding: 14px; | ||
| 5 | + padding-bottom: 8px; | ||
| 6 | + line-height: 24px; | ||
| 7 | + | ||
| 8 | + .browse-button { | ||
| 9 | + @extend .btn; | ||
| 10 | + @extend .btn-small; | ||
| 11 | + float: right; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + .commit-title { | ||
| 15 | + line-height: 26px; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + .commit-description { | ||
| 19 | + font-size: 14px; | ||
| 20 | + padding: 0px; | ||
| 21 | + padding-bottom: 4px; | ||
| 22 | + border: none; | ||
| 23 | + background-color: white; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + .commit-info { | ||
| 27 | + @extend .middle_box_content; | ||
| 28 | + @extend .clearfix; | ||
| 29 | + | ||
| 30 | + padding-bottom: 8px; | ||
| 31 | + padding-top: 8px; | ||
| 32 | + | ||
| 33 | + margin-left: -14px; | ||
| 34 | + margin-right: -14px; | ||
| 35 | + margin-bottom: -8px; | ||
| 36 | + | ||
| 37 | + .author .name, .committer .name { | ||
| 38 | + font-weight: bold; | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + .sha-block { | ||
| 43 | + float: right; | ||
| 44 | + margin-left: 10px | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + &.merge-commit .sha-block { | ||
| 48 | + clear: right; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + .committer { | ||
| 52 | + padding-left: 32px; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + .avatar { | ||
| 56 | + margin-right: 4px; | ||
| 57 | + } | ||
| 58 | +} | ||
| 0 | \ No newline at end of file | 59 | \ No newline at end of file |
app/models/commit.rb
| @@ -106,6 +106,41 @@ class Commit | @@ -106,6 +106,41 @@ class Commit | ||
| 106 | utf8 author.name | 106 | utf8 author.name |
| 107 | end | 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 | + # Was this commit committed by a different person than the original author? | ||
| 140 | + def different_committer? | ||
| 141 | + author_name != committer_name || author_email != committer_email | ||
| 142 | + end | ||
| 143 | + | ||
| 109 | def committer_name | 144 | def committer_name |
| 110 | utf8 committer.name | 145 | utf8 committer.name |
| 111 | end | 146 | end |
app/views/commits/show.html.haml
| 1 | -.main_box | ||
| 2 | - .top_box_content | ||
| 3 | - .right | ||
| 4 | - - unless @notes_count.zero? | ||
| 5 | - %span.btn.small.disabled.padded= pluralize @notes_count, 'note' | 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) | ||
| 8 | + .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 | ||
| 6 | 28 | ||
| 7 | - = link_to tree_project_ref_path(@project, @commit.id), :class => "btn small" do | ||
| 8 | - Browse Code » | ||
| 9 | - = image_tag gravatar_icon(@commit.author_email), :class => "avatar" | ||
| 10 | - %code= @commit.id.to_s | ||
| 11 | - %h5 | ||
| 12 | - = @commit.author_name | ||
| 13 | - %small= @commit.created_at.stamp("Aug 21, 2011 9:23pm") | ||
| 14 | - - if @commit.author_name != @commit.committer_name or @commit.author_email != @commit.committer_email or @commit.authored_date != @commit.committed_date | ||
| 15 | - – | ||
| 16 | - %cite committed by | ||
| 17 | - = @commit.committer_name | ||
| 18 | - %small= @commit.committed_date.stamp("Aug 21, 2011 9:23pm") | ||
| 19 | - | ||
| 20 | - .middle_box_content | ||
| 21 | - %pre.commit_message | ||
| 22 | - = commit_msg_with_link_to_issues(@project, @commit.safe_message) | ||
| 23 | -%br | ||
| 24 | = render "commits/diffs", :diffs => @commit.diffs | 29 | = render "commits/diffs", :diffs => @commit.diffs |
| 25 | = render "notes/notes", :tid => @commit.id, :tt => "commit" | 30 | = render "notes/notes", :tid => @commit.id, :tt => "commit" |
| 26 | = render "notes/per_line_form" | 31 | = render "notes/per_line_form" |