mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
Unescape branch names in compare commit The upgrade in GitLab v7.9 to Rails v4.1.9 caused all branch names in the compare commit mode to be escaped (e.g. `/` to `%2F`). The compare mode would not always work when comparing against branch names with a forward slash. Opted to unescape the branch name rather than use a wildcard segment to prevent escaping slashes because it seems like a more sensible URL. The slashes in this case aren't really represented by a tree structure (e.g. /compare/one/two/branch..another/branch/here). * Closes #1399 * Closes https://github.com/gitlabhq/gitlabhq/issues/9105 See merge request !582
34 lines
778 B
Ruby
34 lines
778 B
Ruby
require 'addressable/uri'
|
|
|
|
class Projects::CompareController < Projects::ApplicationController
|
|
# Authorize
|
|
before_filter :require_non_empty_project
|
|
before_filter :authorize_download_code!
|
|
|
|
def index
|
|
end
|
|
|
|
def show
|
|
base_ref = Addressable::URI.unescape(params[:from])
|
|
head_ref = Addressable::URI.unescape(params[:to])
|
|
|
|
compare_result = CompareService.new.execute(
|
|
current_user,
|
|
@project,
|
|
head_ref,
|
|
@project,
|
|
base_ref
|
|
)
|
|
|
|
@commits = compare_result.commits
|
|
@diffs = compare_result.diffs
|
|
@commit = @commits.last
|
|
@line_notes = []
|
|
end
|
|
|
|
def create
|
|
redirect_to namespace_project_compare_path(@project.namespace, @project,
|
|
params[:from], params[:to])
|
|
end
|
|
end
|