summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-05-04 06:58:56 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-06 14:43:36 +0300
commitfe38be8be459eaf987e734b16074e22f3a88b5b8 (patch)
tree2e90ea204bd41c604d53c477b1986e7d878b7424
parent81634bc1f7d8abb1686ca0cf2318bc02f3c7d97c (diff)
downloadgitlab-ce-fe38be8be459eaf987e734b16074e22f3a88b5b8.tar.gz
Merge branch 'fix-escaped-branches-in-compare' into 'master'
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
-rw-r--r--CHANGELOG4
-rw-r--r--app/controllers/projects/compare_controller.rb6
-rw-r--r--spec/controllers/projects/compare_controller_spec.rb22
3 files changed, 30 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e25f471692a..7165513b506 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,10 @@ v 7.10.0 (unreleased)
- Include commit comments in MR from a forked project.
- Fix adding new group members from admin area
- Add default project and snippet visibility settings to the admin web UI.
+ - Show incompatible projects in Google Code import status (Stan Hu)
+ - Fix bug where commit data would not appear in some subdirectories (Stan Hu)
+ - Unescape branch names in compare commit (Stan Hu)
+ -
- Fix bug where Slack service channel was not saved in admin template settings. (Stan Hu)
- Move snippets UI to fluid layout
- Improve UI for sidebar. Increase separation between navigation and content
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 146808fa562..e1a8a5b6fa3 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -1,3 +1,5 @@
+require 'addressable/uri'
+
class Projects::CompareController < Projects::ApplicationController
# Authorize
before_filter :require_non_empty_project
@@ -7,8 +9,8 @@ class Projects::CompareController < Projects::ApplicationController
end
def show
- base_ref = params[:from]
- head_ref = params[:to]
+ base_ref = Addressable::URI.unescape(params[:from])
+ head_ref = Addressable::URI.unescape(params[:to])
compare_result = CompareService.new.execute(
current_user,
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
new file mode 100644
index 00000000000..23e1566b8f3
--- /dev/null
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe Projects::CompareController do
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
+ let(:ref_from) { "improve%2Fawesome" }
+ let(:ref_to) { "feature" }
+
+ before do
+ sign_in(user)
+ project.team << [user, :master]
+ end
+
+ it 'compare should show some diffs' do
+ get(:show, namespace_id: project.namespace.to_param,
+ project_id: project.to_param, from: ref_from, to: ref_to)
+
+ expect(response).to be_success
+ expect(assigns(:diffs).length).to be >= 1
+ expect(assigns(:commits).length).to be >= 1
+ end
+end