diff options
author | Alexander Randa <randa.alex@gmail.com> | 2017-04-21 15:31:18 +0000 |
---|---|---|
committer | Alexander Randa <randa.alex@gmail.com> | 2017-05-12 11:45:26 +0000 |
commit | fdba7449867ab49aed7cb39449ac41af4bc2d234 (patch) | |
tree | 313347afff39b29a07bfeb96571543112f745e14 /app/models/commit.rb | |
parent | 1b929586387af4db42fc81253ad310260655f829 (diff) | |
download | gitlab-ce-fdba7449867ab49aed7cb39449ac41af4bc2d234.tar.gz |
Fix long urls in the title of commit
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 8b8b3f00202..f21ef76fafc 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 |