FIX: remove diff contents for excerpt

FIX: remove diff contents for excerpt

This leads to very confusing oneboxes

From f106b62266a1dfabd45985dfe138f1defd03cafd Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 4 Dec 2018 15:17:56 +1100
Subject: [PATCH] FIX: remove diff contents for excerpt

This leads to very confusing oneboxes

diff --git a/lib/discourse_code_review/importer.rb b/lib/discourse_code_review/importer.rb
index ac633fc..4dad21c 100644
--- a/lib/discourse_code_review/importer.rb
+++ b/lib/discourse_code_review/importer.rb
@@ -41,7 +41,8 @@ module DiscourseCodeReview
       title = commit[:subject]
       # we add a unicode zero width joiner so code block is not corrupted
       diff = commit[:diff].gsub('`‍``', "`\u200d``")
-      raw = commit[:body] + "\n\n`‍``diff\n#{diff}\n`‍``\n#{link}"
+
+      raw = "<div class='excerpt'>#{commit[:body]}\n</div>\n\n`‍``diff\n#{diff}\n`‍``\n#{link}"
 
       user = ensure_user(
         email: commit[:email],
diff --git a/spec/discourse_code_review/lib/importer_spec.rb b/spec/discourse_code_review/lib/importer_spec.rb
index 7e78814..f76cbb1 100644
--- a/spec/discourse_code_review/lib/importer_spec.rb
+++ b/spec/discourse_code_review/lib/importer_spec.rb
@@ -33,6 +33,7 @@ module DiscourseCodeReview
       post = Importer.new(repo).import_commit(commit)
 
       expect(post.cooked.scan("code").length).to eq(2)
+      expect(post.excerpt).to eq("this is the body")
     end
   end
 end

GitHub

1 Like