Sha256: bf6229f50ad321d6359f78f9d796b8fb6d4c4a96fdc1eef58a9f03be52ca03a2

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

class CommitFilter::Commit::DiffsController < CommitFilter::ApplicationController
  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(
        t('commit_filter.diff.errors.diff_length_not_one', length: 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: t('commit_filter.general.errors.internal_server_error')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commit_filter-0.1.1 app/controllers/commit_filter/commit/diffs_controller.rb
commit_filter-0.1.0 app/controllers/commit_filter/commit/diffs_controller.rb