FIX: Use full git sha instead of partial git sha in post (#64)

FIX: Use full git sha instead of partial git sha in post (#64)

The partial sha is generally less useful, and using the full sha enables better searching, because you can search by partial or full commit sha. Also reduces the odds of clashing across repos.

diff --git a/lib/discourse_code_review/state/commit_topics.rb b/lib/discourse_code_review/state/commit_topics.rb
index 290f9f9..64e81fb 100644
--- a/lib/discourse_code_review/state/commit_topics.rb
+++ b/lib/discourse_code_review/state/commit_topics.rb
@@ -74,9 +74,9 @@ module DiscourseCodeReview::State::CommitTopics
           body, linked_topics = auto_link_commits(commit[:body])
           linked_topics.merge! find_linked_commits(title)
 
-          short_hash = "<small>sha: #{commit[:hash][0...8]}</small>"
+          hash_html = "<small>sha: #{commit[:hash]}</small>"
 
-          raw = "[excerpt]\n#{body}\n[/excerpt]\n\n`‍``diff\n#{diff}\n#{truncated_message}`‍``\n#{link} #{short_hash}"
+          raw = "[excerpt]\n#{body}\n[/excerpt]\n\n`‍``diff\n#{diff}\n#{truncated_message}`‍``\n#{link} #{hash_html}"
 
           topic = find_topic_by_commit_hash(commit[:hash])
 
diff --git a/spec/jobs/code_review_sync_commits_spec.rb b/spec/jobs/code_review_sync_commits_spec.rb
index 39dc53e..93f3b19 100644
--- a/spec/jobs/code_review_sync_commits_spec.rb
+++ b/spec/jobs/code_review_sync_commits_spec.rb
@@ -35,12 +35,17 @@ describe Jobs::CodeReviewSyncCommits, type: :code_review_integration do
       )
     end
 
-    it "creates a commit topic and a category topic" do
+    it "creates a commit topic and a category topic, with a full sha in the first post" do
       expect {
         described_class.new.execute(repo_name: '10xninjarockstar/ultimatetodolist', repo_id: 24)
       }.to change { Topic.count }.by(2)
 
       topics = Topic.order('id desc').limit(2)
+
+      commit_post = topics.first.first_post
+
+      hash = topics.first.custom_fields[DiscourseCodeReview::COMMIT_HASH]
+      expect(commit_post.raw).to include("sha: #{hash}")
     end
   end
 end

GitHub sha: 6cc8a9c1

This commit appears in #64 which was approved by SamSaffron. It was merged by martin.