diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-06-08 10:32:45 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-06-08 10:32:45 +0000 |
commit | 8ce11fc388bc168368b1e0a65659bb45c76a4a08 (patch) | |
tree | a362da980183366799d64c07154c6948d711e2d2 /app/models/commit.rb | |
parent | 05e88a0d12b5ae79fcd5a7e26a5eb1bb259843ec (diff) | |
parent | fdba7449867ab49aed7cb39449ac41af4bc2d234 (diff) | |
download | gitlab-ce-8ce11fc388bc168368b1e0a65659bb45c76a4a08.tar.gz |
Merge branch '12614-fix-long-message' into 'master'
Fix long urls in the title of commit
Closes #12614
See merge request !10938
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 1a766c9f6d0..20206d57c4c 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -114,16 +114,16 @@ class Commit # # Usually, the commit title is the first line of the commit message. # In case this first line is longer than 100 characters, it is cut off - # after 80 characters and ellipses (`&hellp;`) are appended. + # after 80 characters + `...` def title - full_title.length > 100 ? full_title[0..79] << "…" : full_title + return full_title if full_title.length < 100 + + full_title.truncate(81, separator: ' ', omission: '…') end # Returns the full commits title def full_title - return @full_title if @full_title - - @full_title = + @full_title ||= if safe_message.blank? no_commit_message else @@ -131,19 +131,14 @@ class Commit end end - # Returns the commits description - # - # cut off, ellipses (`&hellp;`) are prepended to the commit message. + # Returns full commit message if title is truncated (greater than 99 characters) + # otherwise returns commit message without first line def description - title_end = safe_message.index("\n") - @description ||= - if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) - "…" << safe_message[80..-1] - else - safe_message.split("\n", 2)[1].try(:chomp) - end - end + return safe_message if full_title.length >= 100 + safe_message.split("\n", 2)[1].try(:chomp) + end + def description? description.present? end |