FIX: allow brackets as sha regex boundaries (#2)

FIX: allow brackets as sha regex boundaries (#2)
diff --git a/lib/discourse_code_review/importer.rb b/lib/discourse_code_review/importer.rb
index e43a3e2..70ce49a 100644
--- a/lib/discourse_code_review/importer.rb
+++ b/lib/discourse_code_review/importer.rb
@@ -49,7 +49,7 @@ module DiscourseCodeReview
     def find_linked_commits(text)
       result = {}
 
-      shas = text.scan(/(?:\s|^)([a-f0-9]{8,})(?:\s|$)/).flatten
+      shas = text.scan(/(?:\s|\(|^)([a-f0-9]{8,})(?:\s|\)|$)/).flatten
       if shas.length > 0
 
         like_clause = shas.map { |sha| "f.value LIKE '#{sha}%'" }.join(' OR ')
diff --git a/spec/discourse_code_review/lib/importer_spec.rb b/spec/discourse_code_review/lib/importer_spec.rb
index 1bd2ed3..a96ba08 100644
--- a/spec/discourse_code_review/lib/importer_spec.rb
+++ b/spec/discourse_code_review/lib/importer_spec.rb
@@ -33,7 +33,7 @@ module DiscourseCodeReview
       post = Importer.new(repo).import_commit(commit)
 
       commit[:hash] = "dbbadb5c357bc23daf1fa732f8670e55dc28b7cb"
-      commit[:body] = "ab2787347ff this is\nfollowing up on a1db15fe"
+      commit[:body] = "ab2787347ff (this is\nfollowing up on a1db15fe)"
       post2 = Importer.new(repo).import_commit(commit)
 
       expect(post2.cooked).to include(post.topic.url)

GitHub
sha: ffc714a1

1 Like