try forcing checkouts

try forcing checkouts

seeing conflicting states in repo that need cleanup

From 47c55935c5b1a41eb501a6ec6fe453ce4c0b6c1f Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 27 Nov 2018 20:13:14 +1100
Subject: [PATCH] try forcing checkouts

seeing conflicting states in repo that need cleanup

diff --git a/lib/discourse_code_review/github_repo.rb b/lib/discourse_code_review/github_repo.rb
index e51e094..9d14ee1 100644
--- a/lib/discourse_code_review/github_repo.rb
+++ b/lib/discourse_code_review/github_repo.rb
@@ -43,7 +43,7 @@ module DiscourseCodeReview
 
     def commit_comments(page = nil)
       # TODO add a distributed lock here
-      git("checkout master")
+      git("checkout -f master")
       git("pull")
 
       page ||= current_comment_page
@@ -54,9 +54,9 @@ module DiscourseCodeReview
 
         if hash[:path].present? && hash[:position].present?
 
-          git("checkout #{hash[:commit_id]}")
+          git("checkout -f #{hash[:commit_id]}")
           if !File.exist?("#{path}#{hash[:path]}")
-            git("checkout #{hash[:commit_id]}~1")
+            git("checkout -f #{hash[:commit_id]}~1")
           end
 
           diff = ""
@@ -64,7 +64,7 @@ module DiscourseCodeReview
             diff = git("diff #{hash[:commit_id]}~1 #{hash[:commit_id]} #{hash[:path]}")
           end
 
-          git("checkout master")
+          git("checkout -f master")
 
           if diff.present?
             # 5 is preamble
@@ -93,7 +93,7 @@ module DiscourseCodeReview
     end
 
     def commits_since(hash = nil)
-      git("checkout master")
+      git("checkout -f master")
       git("pull")
 
       hash ||= last_commit

GitHub

1 Like