summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-08-22 08:37:48 +0000
committerRémy Coutable <remy@rymai.me>2018-08-22 08:37:48 +0000
commite03728013db9956c1749efa38f69d9a6f3f7ecf1 (patch)
treea73a22eff70df383f67a5a2e548e1c9a96454bb5
parentfd4e02920321a96c3de9bc0f7d2aca0ada77588f (diff)
parent26cc7ee6afc12075a343d1ba30f2ad14d4173b7d (diff)
downloadgitlab-ce-e03728013db9956c1749efa38f69d9a6f3f7ecf1.tar.gz
Merge branch 'yisiliang/gitlab-ce-avoid-nil-safe_message' into 'master'
Avoid nil safe message See merge request gitlab-org/gitlab-ce!21326
-rw-r--r--app/models/commit.rb1
-rw-r--r--changelogs/unreleased/21326-avoid-nil-safe-message.yml5
-rw-r--r--spec/models/commit_spec.rb6
3 files changed, 12 insertions, 0 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 27fbdc3e386..594972ad344 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -193,6 +193,7 @@ class Commit
# otherwise returns commit message without first line
def description
return safe_message if full_title.length >= 100
+ return no_commit_message if safe_message.blank?
safe_message.split("\n", 2)[1].try(:chomp)
end
diff --git a/changelogs/unreleased/21326-avoid-nil-safe-message.yml b/changelogs/unreleased/21326-avoid-nil-safe-message.yml
new file mode 100644
index 00000000000..ca1a89191a8
--- /dev/null
+++ b/changelogs/unreleased/21326-avoid-nil-safe-message.yml
@@ -0,0 +1,5 @@
+---
+title: "Avoid nil safe message"
+merge_request: 21326
+author: Yi Siliang
+type: fixed
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 5157d8fc645..d5f88e930d4 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -225,6 +225,12 @@ eos
end
describe 'description' do
+ it 'returns no_commit_message when safe_message is blank' do
+ allow(commit).to receive(:safe_message).and_return(nil)
+
+ expect(commit.description).to eq('--no commit message')
+ end
+
it 'returns description of commit message if title less than 100 characters' do
message = <<eos
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.