2015-09-11 14:41:01 +05:30
|
|
|
require 'addressable/uri'
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
class Projects::CompareController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
def index
|
2015-09-11 14:41:01 +05:30
|
|
|
@ref = Addressable::URI.unescape(params[:to])
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2015-09-11 14:41:01 +05:30
|
|
|
base_ref = Addressable::URI.unescape(params[:from])
|
|
|
|
@ref = head_ref = Addressable::URI.unescape(params[:to])
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
compare_result = CompareService.new.
|
|
|
|
execute(@project, head_ref, @project, base_ref)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
if compare_result
|
|
|
|
@commits = compare_result.commits
|
|
|
|
@diffs = compare_result.diffs
|
|
|
|
@commit = @commits.last
|
|
|
|
@line_notes = []
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-04-26 12:48:37 +05:30
|
|
|
redirect_to namespace_project_compare_path(@project.namespace, @project,
|
|
|
|
params[:from], params[:to])
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|