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