Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-07-26 12:17:34 +0300
committerStan Hu <stanhu@gmail.com>2015-07-26 13:47:01 +0300
commit562242cb9dc11f0a5957a58eb9f91a484a909b40 (patch)
treea2e84f4464044c9c9286253d04783a1684934e53
parent4a76cbe21907b92e53b168f3085c19d00be11f0b (diff)
Fix commit data retrieval when branch name has single quotes
Closes #1724
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/refs_controller.rb6
-rw-r--r--app/views/projects/refs/logs_tree.js.haml8
-rw-r--r--app/views/projects/tree/_tree.html.haml2
-rw-r--r--features/project/source/browse_files.feature7
-rw-r--r--features/steps/project/source/browse_files.rb17
-rw-r--r--spec/support/test_env.rb3
7 files changed, 39 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1ca4c7a8480..024be16708e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
+ - Fix commit data retrieval when branch name has single quotes (Stan Hu)
- Fix Error 500 when browsing projects with no HEAD (Stan Hu)
- Fix full screen mode for snippet comments (Daniel Gerhardt)
- Fix 404 error in files view after deleting the last file in a repository (Stan Hu)
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index d83561cf32a..6080c849c8d 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -1,5 +1,6 @@
class Projects::RefsController < Projects::ApplicationController
include ExtractsPath
+ include TreeHelper
before_action :require_non_empty_project
before_action :assign_ref_vars
@@ -60,6 +61,11 @@ class Projects::RefsController < Projects::ApplicationController
}
end
+ if @logs.present?
+ @log_url = namespace_project_tree_url(@project.namespace, @project, tree_join(@ref, @path || '/'))
+ @more_log_url = logs_file_namespace_project_ref_path(@project.namespace, @project, @ref, @path || '', offset: (@offset + @limit))
+ end
+
respond_to do |format|
format.html { render_404 }
format.js
diff --git a/app/views/projects/refs/logs_tree.js.haml b/app/views/projects/refs/logs_tree.js.haml
index 35c15cf3a9e..db7f244d002 100644
--- a/app/views/projects/refs/logs_tree.js.haml
+++ b/app/views/projects/refs/logs_tree.js.haml
@@ -11,9 +11,11 @@
- if @logs.present?
:plain
var current_url = location.href.replace(/\/?$/, '/');
- var log_url = '#{namespace_project_tree_url(@project.namespace, @project, tree_join(@ref, @path || '/'))}'.replace(/\/?$/, '/');
+ var log_url = "#{escape_javascript(@log_url)}".replace(/\/?$/, '/');
+
if(current_url == log_url) {
- // Load 10 more commit log for each file in tree
+ // Load more commit logs for each file in tree
// if we still on the same page
- ajaxGet('#{logs_file_namespace_project_ref_path(@project.namespace, @project, @ref, @path || '', offset: (@offset + @limit))}');
+ var url = "#{escape_javascript(@more_log_url)}";
+ ajaxGet(url);
}
diff --git a/app/views/projects/tree/_tree.html.haml b/app/views/projects/tree/_tree.html.haml
index d304690d162..5048154cb2f 100644
--- a/app/views/projects/tree/_tree.html.haml
+++ b/app/views/projects/tree/_tree.html.haml
@@ -49,5 +49,5 @@
:javascript
// Load last commit log for each file in tree
$('#tree-slider').waitForImages(function() {
- ajaxGet('#{@logs_path}');
+ ajaxGet("#{escape_javascript(@logs_path)}");
});
diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature
index af68cb96ed9..d3a77466a35 100644
--- a/features/project/source/browse_files.feature
+++ b/features/project/source/browse_files.feature
@@ -158,3 +158,10 @@ Feature: Project Source Browse Files
Given I visit project source page for "6d394385cf567f80a8fd85055db1ab4c5295806f"
And I click on ".gitignore" file in repo
Then I don't see the permalink link
+
+ @javascript
+ Scenario: I browse code with single quotes in the ref
+ Given I switch ref to 'test'
+ And I see the ref 'test' has been selected
+ And I visit the 'test' tree
+ Then I see the commit data
diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb
index 95879b9544d..5cb085db207 100644
--- a/features/steps/project/source/browse_files.rb
+++ b/features/steps/project/source/browse_files.rb
@@ -193,6 +193,23 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
FileUtils.rm_f(File.join(@project.repository.path, 'hooks', 'pre-receive'))
end
+ step "I switch ref to 'test'" do
+ select "'test'", from: 'ref'
+ end
+
+ step "I see the ref 'test' has been selected" do
+ expect(page).to have_selector '.select2-chosen', text: "'test'"
+ end
+
+ step "I visit the 'test' tree" do
+ visit namespace_project_tree_path(@project.namespace, @project, "'test'")
+ end
+
+ step 'I see the commit data' do
+ expect(page).to have_css('.tree-commit-link', visible: true)
+ expect(page).not_to have_content('Loading commit data...')
+ end
+
private
def set_new_content
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index dcf2a9e2ce5..dab4535e2c7 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -12,7 +12,8 @@ module TestEnv
'fix' => '12d65c8',
'improve/awesome' => '5937ac0',
'markdown' => '0ed8c6c',
- 'master' => '5937ac0'
+ 'master' => '5937ac0',
+ "'test'" => 'e56497b',
}
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily