Commit f1e1e5bf0deb641f73f016991b749963f9baf855

Authored by Dmitriy Zaporozhets
2 parents 5bdcdcd8 2c28dbd2

Merge pull request #6412 from skv-headless/commit_description

commit description in commit list
app/assets/stylesheets/sections/commits.scss
... ... @@ -168,6 +168,32 @@ li.commit {
168 168 text-decoration: underline;
169 169 }
170 170 }
  171 +
  172 + .text-expander {
  173 + background: #ddd;
  174 + color: #555;
  175 + padding: 0 5px;
  176 + line-height: 6px;
  177 + height: 12px;
  178 + font-size: 12px;
  179 + font-weight: bold;
  180 + vertical-align: middle;
  181 + display: inline-block;
  182 + border-radius: 1px;
  183 + text-decoration: none;
  184 + cursor: pointer;
  185 + &:hover {
  186 + background-color: #ccc;
  187 + }
  188 + }
  189 + }
  190 +
  191 + .commit-row-description {
  192 + font-size: 14px;
  193 + border-left: 1px solid #e5e5e5;
  194 + padding: 0 15px 0 7px;
  195 + margin: 5px 0 10px 5px;
  196 + display: none;
171 197 }
172 198  
173 199 .commit-row-info {
... ... @@ -192,4 +218,10 @@ li.commit {
192 218 @extend .cgray;
193 219 }
194 220 }
  221 +
  222 + &.open {
  223 + .commit-row-description {
  224 + display: block;
  225 + }
  226 + }
195 227 }
... ...
app/models/commit.rb
... ... @@ -99,14 +99,16 @@ class Commit
99 99 #
100 100 # cut off, ellipses (`&hellp;`) are prepended to the commit message.
101 101 def description
102   - description = safe_message
  102 + title_end = safe_message.index(/\n/)
  103 + @description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100)
  104 + "&hellip;".html_safe << safe_message[80..-1]
  105 + else
  106 + safe_message.split(/\n/, 2)[1].try(:chomp)
  107 + end
  108 + end
103 109  
104   - title_end = description.index(/\n/)
105   - if (!title_end && description.length > 100) || (title_end && title_end > 100)
106   - "&hellip;".html_safe << description[80..-1]
107   - else
108   - description.split(/\n/, 2)[1].try(:chomp)
109   - end
  110 + def description?
  111 + description.present?
110 112 end
111 113  
112 114 # Regular expression that identifies commit message clauses that trigger issue closing.
... ...
app/views/projects/commits/_commit.html.haml
1 1 %li.commit
2   - .commit-row-title
  2 + .commit-row-title{"data-toggle" => "dropdown"}
3 3 = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
4 4 &nbsp;
5 5 %span.str-truncated
6 6 = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message"
  7 + - if commit.description?
  8 + %span.label-default.text-expander.js-details-target ...
  9 +
7 10 = link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right"
8 11 .notes_count
9 12 - notes = project.notes.for_commit_id(commit.id)
... ... @@ -12,6 +15,10 @@
12 15 %i.icon-comment
13 16 = notes.count
14 17  
  18 + - if commit.description?
  19 + .commit-row-description
  20 + = simple_format(commit.description)
  21 +
15 22 .commit-row-info
16 23 = commit_author_link(commit, avatar: true, size: 16)
17 24 .committed_ago
... ...