From fdba7449867ab49aed7cb39449ac41af4bc2d234 Mon Sep 17 00:00:00 2001 From: Alexander Randa Date: Fri, 21 Apr 2017 15:31:18 +0000 Subject: Fix long urls in the title of commit --- app/models/commit.rb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'app/models/commit.rb') 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 -- cgit v1.2.1 From 204db05637076b832adff113dc15615587b81523 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Wed, 7 Jun 2017 14:21:39 +0200 Subject: Re-enable Gitaly commit_raw_diffs migration --- app/models/commit.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index bfa3a624e70..1a766c9f6d0 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -326,12 +326,11 @@ class Commit end def raw_diffs(*args) - # Uncomment when https://gitlab.com/gitlab-org/gitaly/merge_requests/170 is merged - # if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) - # Gitlab::GitalyClient::Commit.new(project.repository).diff_from_parent(self, *args) - # else - raw.diffs(*args) - # end + if Gitlab::GitalyClient.feature_enabled?(:commit_raw_diffs) + Gitlab::GitalyClient::Commit.new(project.repository).diff_from_parent(self, *args) + else + raw.diffs(*args) + end end def raw_deltas -- cgit v1.2.1