Sha256: 4f42165aaebdfaf6bd62f3c23b373e629bcd5e14b0dff5fe61444cec82bd78e7

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

class RailsInfo::VersionControl::DiffsController < RailsInfoController
  def new
    repository = Grit::Repo.new(params[:repository_path])

    diff = repository.diff(
      repository.commit(params[:rev_to]), repository.commit(params[:rev]), params[:path]
    )
    
    unless diff.length == 1
      raise NotImplementedError.new("Diff length != 1 but #{diff.length}")
    end
    
    render text: DiffToHtml::GitConverter.new.get_single_file_diff_body(diff.first.diff)
  rescue Exception => e
    if Rails.env.development?
      raise e.class.name + ': ' + e.message + ' ... ' + e.backtrace.join("\n")
    else
      logger.error e.class.name + ': ' + e.message + ' ... ' + e.backtrace.join("\n")
      render text: 'Internal server error.'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_info-0.1.1 app/controllers/rails_info/version_control/diffs_controller.rb