FIX: Do not parse emoji in commit message (#79)

FIX: Do not parse emoji in commit message (#79)

The commit message is converted to HTML and back to Markdown to link other commits. When this happened, Emojis were converted to img HTML tags and then to image Markdown. This commit disables emojis parser to avoid images being inserted in commit message.

diff --git a/lib/discourse_code_review/state/commit_topics.rb b/lib/discourse_code_review/state/commit_topics.rb
index 64e81fb..7c6d53b 100644
--- a/lib/discourse_code_review/state/commit_topics.rb
+++ b/lib/discourse_code_review/state/commit_topics.rb
@@ -5,7 +5,7 @@ module DiscourseCodeReview::State::CommitTopics
     def auto_link_commits(text, doc = nil)
       linked_commits = find_linked_commits(text)
       if (linked_commits.length > 0)
-        doc ||= Nokogiri::HTML5::fragment(PrettyText.cook(text))
+        doc ||= Nokogiri::HTML5::fragment(PrettyText.cook(text, disable_emojis: true))
         skip_tags = ["a", "code"]
         linked_commits.each do |hash, topic|
           doc.traverse do |node|
diff --git a/spec/discourse_code_review/lib/importer_spec.rb b/spec/discourse_code_review/lib/importer_spec.rb
index 88a645c..799cacb 100644
--- a/spec/discourse_code_review/lib/importer_spec.rb
+++ b/spec/discourse_code_review/lib/importer_spec.rb
@@ -201,5 +201,26 @@ module DiscourseCodeReview
 
       expect(followee.tags.pluck(:name)).not_to include(SiteSetting.code_review_approved_tag)
     end
+
+    it "does not parse emojis in commit message" do
+      repo = GithubRepo.new("discourse/discourse", Octokit::Client.new, nil, repo_id: 24)
+      repo.expects(:default_branch_contains?).with('154f503d2e99f904356b52f2fae9edcc495708fa').returns(true)
+      repo.expects(:followees).with('154f503d2e99f904356b52f2fae9edcc495708fa').returns([])
+
+      commit = {
+        subject: "hello world",
+        body: "this is the body\nwith an emoji :)",
+        email: "sam@sam.com",
+        github_login: "sam",
+        github_id: "111",
+        date: 1.day.ago,
+        diff: "`‍``\nwith a diff",
+        hash: "154f503d2e99f904356b52f2fae9edcc495708fa"
+      }
+
+      topic = Topic.find(Importer.new(repo).import_commit(commit))
+      expect(topic.tags.pluck(:name)).not_to include(SiteSetting.code_review_approved_tag)
+      expect(topic.posts.pluck_first(:raw)).to include("with an emoji :)")
+    end
   end
 end

GitHub sha: dcba74bc0b57c4c376fa0984d432de0ee1274f5c

This commit appears in #79 which was approved by eviltrout and ZogStriP. It was merged by nbianca.