2015-04-27 02:42:29 -04:00
|
|
|
require 'addressable/uri'
|
|
|
|
|
2013-06-23 12:47:22 -04:00
|
|
|
class Projects::CompareController < Projects::ApplicationController
|
2012-09-20 15:20:48 -04:00
|
|
|
# Authorize
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
2012-09-20 15:20:48 -04:00
|
|
|
|
2012-09-25 23:10:50 -04:00
|
|
|
def index
|
2015-05-09 16:25:46 -04:00
|
|
|
@ref = Addressable::URI.unescape(params[:to])
|
2012-09-25 23:10:50 -04:00
|
|
|
end
|
|
|
|
|
2012-09-20 15:20:48 -04:00
|
|
|
def show
|
2015-04-27 02:42:29 -04:00
|
|
|
base_ref = Addressable::URI.unescape(params[:from])
|
2015-05-09 16:25:46 -04:00
|
|
|
@ref = head_ref = Addressable::URI.unescape(params[:to])
|
2012-09-20 15:20:48 -04:00
|
|
|
|
2015-08-11 08:33:31 -04:00
|
|
|
compare_result = CompareService.new.
|
|
|
|
execute(@project, head_ref, @project, base_ref)
|
2014-07-29 05:33:51 -04:00
|
|
|
|
2015-09-18 15:02:01 -04:00
|
|
|
if compare_result
|
|
|
|
@commits = compare_result.commits
|
|
|
|
@diffs = compare_result.diffs
|
|
|
|
@commit = @commits.last
|
|
|
|
@line_notes = []
|
|
|
|
end
|
2012-09-20 15:20:48 -04:00
|
|
|
end
|
2012-09-25 23:10:50 -04:00
|
|
|
|
|
|
|
def create
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to namespace_project_compare_path(@project.namespace, @project,
|
|
|
|
params[:from], params[:to])
|
2012-09-25 23:10:50 -04:00
|
|
|
end
|
2012-09-20 15:20:48 -04:00
|
|
|
end
|