making changes like this to the repo is cause bad side effects

making changes like this to the repo is cause bad side effects

revert majority of previous fixes

also revert hijack so webhook only has 30 secs

From 48d0d0e6510be62927564480f4013e947f5b0129 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 27 Nov 2018 21:38:36 +1100
Subject: [PATCH] making changes like this to the repo is cause bad side
 effects

revert majority of previous fixes

also revert hijack so webhook only has 30 secs

diff --git a/app/controllers/discourse_code_review/code_review_controller.rb b/app/controllers/discourse_code_review/code_review_controller.rb
index f82688d..2db768e 100644
--- a/app/controllers/discourse_code_review/code_review_controller.rb
+++ b/app/controllers/discourse_code_review/code_review_controller.rb
@@ -34,21 +34,19 @@ module DiscourseCodeReview
       repo = params["repository"]
       repo_name = repo["full_name"] if repo
 
-      hijack do
-        if ["commit_comment", "push"].include? type
-          client = DiscourseCodeReview.octokit_client
-          repo = GithubRepo.new(repo_name, client)
-          importer = Importer.new(repo)
-
-          if type == "commit_comment"
-            importer.import_comments
-          elsif type == "push"
-            importer.import_commits
-          end
+      if ["commit_comment", "push"].include? type
+        client = DiscourseCodeReview.octokit_client
+        repo = GithubRepo.new(repo_name, client)
+        importer = Importer.new(repo)
+
+        if type == "commit_comment"
+          importer.import_comments
+        elsif type == "push"
+          importer.import_commits
         end
-
-        render plain: '"ok"'
       end
+
+      render plain: '"ok"'
     end
 
     def followup
diff --git a/lib/discourse_code_review/github_repo.rb b/lib/discourse_code_review/github_repo.rb
index 3a171eb..5bdcd7b 100644
--- a/lib/discourse_code_review/github_repo.rb
+++ b/lib/discourse_code_review/github_repo.rb
@@ -43,7 +43,6 @@ module DiscourseCodeReview
 
     def commit_comments(page = nil)
       # TODO add a distributed lock here
-      git("checkout -f master", raise_error: false)
       git("pull")
 
       page ||= current_comment_page
@@ -54,18 +53,7 @@ module DiscourseCodeReview
 
         if hash[:path].present? && hash[:position].present?
 
-          git("checkout -f #{hash[:commit_id]}", raise_error: false)
-          if !File.exist?("#{path}#{hash[:path]}")
-            git("checkout -f #{hash[:commit_id]}~1", raise_error: false)
-          end
-
-          diff = ""
-          if !File.exist?("#{path}#{hash[:path]}")
-            diff = git("diff #{hash[:commit_id]}~1 #{hash[:commit_id]} #{hash[:path]}", raise_error: false)
-          end
-
-          git("checkout -f master", raise_error: false)
-
+          diff = git("diff #{hash[:commit_id]}~1 #{hash[:commit_id]} #{hash[:path]}", raise_error: false)
           if diff.present?
             # 5 is preamble
             start = [hash[:position] + 5 - 3, 5].max
@@ -93,7 +81,6 @@ module DiscourseCodeReview
     end
 
     def commits_since(hash = nil)
-      git("checkout -f master", raise_error: false)
       git("pull")
 
       hash ||= last_commit

GitHub