     :ok
   end
 
-  defp bisect(patches) do
+  defp bisect(patches, project) do
     count = Enum.count(patches)
     if count > 1 do
-      project = patches[0].project
       {patches_lo, patches_hi} = Enum.split(patches, div(count, 2))
       make_batch(patches_lo, project.id)
       make_batch(patches_hi, project.id)

    patches = batch.id
    |> Patch.all_for_batch()
    |> Repo.all()
    state = bisect(patches)
    send_message(repo_conn, patches, {state, erred})
    Project.ping!(project.id)
  end

          commit_message: commit_message}))
    case head do
      :conflict ->
        state = bisect(patches, project)
        send_message(repo_conn, patches, {:conflict, state})
      commit ->
        state = setup_statuses(repo_conn, batch, patches)
