summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-04-21 13:41:11 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-04-21 13:41:11 +0000
commit0625b15a481b3a3edd88110b3c18031ad9068d2f (patch)
treec382ff09cfb221b492fa14372827bea358f293ae
parent81112b54051c99c7546b282c47edc176f0aebd40 (diff)
parentabdc4cbef23a14540cc4526d0e5af23852ce1119 (diff)
downloadgitlab-ce-0625b15a481b3a3edd88110b3c18031ad9068d2f.tar.gz
Merge branch '7-10-rc5' into '7-10-stable'
7.10.0.rc5 cc @job See merge request !1787
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock4
-rw-r--r--app/controllers/help_controller.rb56
-rw-r--r--app/controllers/import/google_code_controller.rb2
-rw-r--r--app/views/help/show.html.haml2
-rw-r--r--app/views/import/google_code/new_user_map.html.haml28
-rw-r--r--config/initializers/mime_types.rb3
-rw-r--r--config/routes.rb2
-rw-r--r--doc/update/6.x-or-7.x-to-7.10.md2
-rw-r--r--features/steps/dashboard/help.rb2
-rw-r--r--lib/gitlab/google_code_import/importer.rb67
-rw-r--r--spec/controllers/help_controller_spec.rb61
-rw-r--r--spec/features/help_pages_spec.rb2
-rw-r--r--spec/lib/gitlab/google_code_import/importer_spec.rb7
-rw-r--r--spec/routing/routing_spec.rb59
15 files changed, 200 insertions, 99 deletions
diff --git a/Gemfile b/Gemfile
index 1c2a9002204..3522937f18e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -42,7 +42,7 @@ gem "browser"
gem "gitlab_git", '~> 7.1.10'
# Ruby/Rack Git Smart-HTTP Server Handler
-gem 'gitlab-grack', '~> 2.0.0.rc2', require: 'grack'
+gem 'gitlab-grack', '~> 2.0.1', require: 'grack'
# LDAP Auth
gem 'gitlab_omniauth-ldap', '1.2.1', require: "omniauth-ldap"
diff --git a/Gemfile.lock b/Gemfile.lock
index 360b1abcf56..fbf0ef443a1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -199,7 +199,7 @@ GEM
gitlab-flowdock-git-hook (0.4.2.2)
gitlab-grit (>= 2.4.1)
multi_json
- gitlab-grack (2.0.0)
+ gitlab-grack (2.0.1)
rack (~> 1.5.1)
gitlab-grit (2.7.2)
charlock_holmes (~> 0.6)
@@ -700,7 +700,7 @@ DEPENDENCIES
gemnasium-gitlab-service (~> 0.2)
github-markup
gitlab-flowdock-git-hook (~> 0.4.2)
- gitlab-grack (~> 2.0.0.rc2)
+ gitlab-grack (~> 2.0.1)
gitlab-linguist (~> 3.0.1)
gitlab_emoji (~> 0.1)
gitlab_git (~> 7.1.10)
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 0e5567c7734..35ece5b270b 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -3,40 +3,54 @@ class HelpController < ApplicationController
end
def show
- @filepath = clean_path_info(params[:filepath])
- @format = params[:format]
+ category = clean_path_info(path_params[:category])
+ file = path_params[:file]
respond_to do |format|
- format.md { render_doc }
- format.all { send_file_data }
- end
- end
+ format.any(:markdown, :md, :html) do
+ path = Rails.root.join('doc', category, "#{file}.md")
- def shortcuts
- end
+ if File.exist?(path)
+ @markdown = File.read(path)
- private
+ render 'show.html.haml'
+ else
+ # Force template to Haml
+ render 'errors/not_found.html.haml', layout: 'errors', status: 404
+ end
+ end
+
+ # Allow access to images in the doc folder
+ format.any(:png, :gif, :jpeg) do
+ path = Rails.root.join('doc', category, "#{file}.#{params[:format]}")
+
+ if File.exist?(path)
+ send_file(path, disposition: 'inline')
+ else
+ head :not_found
+ end
+ end
- def render_doc
- if File.exists?(Rails.root.join('doc', @filepath + '.md'))
- render 'show.html.haml'
- else
- not_found!
+ # Any other format we don't recognize, just respond 404
+ format.any { head :not_found }
end
end
- def send_file_data
- path = Rails.root.join('doc', "#{@filepath}.#{@format}")
- if File.exists?(path)
- send_file(path, disposition: 'inline')
- else
- head :not_found
- end
+ def shortcuts
end
def ui
end
+ private
+
+ def path_params
+ params.require(:category)
+ params.require(:file)
+
+ params
+ end
+
PATH_SEPS = Regexp.union(*[::File::SEPARATOR, ::File::ALT_SEPARATOR].compact)
# Taken from ActionDispatch::FileHandler
diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb
index 73c912e285b..6574be91920 100644
--- a/app/controllers/import/google_code_controller.rb
+++ b/app/controllers/import/google_code_controller.rb
@@ -68,7 +68,7 @@ class Import::GoogleCodeController < Import::BaseController
def status
unless client.valid?
- return redirect_to new_import_google_path
+ return redirect_to new_import_google_code_path
end
@repos = client.repos
diff --git a/app/views/help/show.html.haml b/app/views/help/show.html.haml
index f22aa92caf7..cc1be6a717a 100644
--- a/app/views/help/show.html.haml
+++ b/app/views/help/show.html.haml
@@ -1,2 +1,2 @@
.documentation.wiki
- = markdown File.read(Rails.root.join('doc', @filepath + '.md')).gsub("$your_email", current_user.email)
+ = markdown @markdown.gsub('$your_email', current_user.email)
diff --git a/app/views/import/google_code/new_user_map.html.haml b/app/views/import/google_code/new_user_map.html.haml
index d55fcfc97a8..9c6824ecad7 100644
--- a/app/views/import/google_code/new_user_map.html.haml
+++ b/app/views/import/google_code/new_user_map.html.haml
@@ -8,9 +8,31 @@
Customize how Google Code email addresses and usernames are imported into GitLab.
In the next step, you'll be able to select the projects you want to import.
%p
- The user map is a JSON document mapping Google Code users (as keys) to the way they will be imported into GitLab (as values). By default the username is masked to ensure users' privacy.
- %p
- To map a Google Code user to a full name or GitLab user, simply replace the value, e.g. <code>"johnsmith@gmail.com": "John Smith"</code> or <code>"johnsmith@gmail.com": "@johnsmith"</code>. Be sure to preserve the surrounding double quotes and other punctuation.
+ The user map is a JSON document mapping the Google Code users that participated on your projects to the way their email addresses and usernames will be imported into GitLab. You can change this by changing the value on the right hand side of <code>:</code>. Be sure to preserve the surrounding double quotes, other punctuation and the email address or username on the left hand side.
+ %ul
+ %li
+ %strong Default: Directly import the Google Code email address or username
+ %p
+ <code>"johnsmith@example.com": "johnsm...@example.com"</code>
+ will add "By johnsm...@example.com" to all issues and comments originally created by johnsmith@example.com.
+ The email address or username is masked to ensure the user's privacy.
+ %li
+ %strong Map a Google Code user to a GitLab user
+ %p
+ <code>"johnsmith@example.com": "@johnsmith"</code>
+ will add "By <a href="#">@johnsmith</a>" to all issues and comments originally created by johnsmith@example.com,
+ and will set <a href="#">@johnsmith</a> as the assignee on all issues originally assigned to johnsmith@example.com.
+ %li
+ %strong Map a Google Code user to a full name
+ %p
+ <code>"johnsmith@example.com": "John Smith"</code>
+ will add "By John Smith" to all issues and comments originally created by johnsmith@example.com.
+ %li
+ %strong Map a Google Code user to a full email address
+ %p
+ <code>"johnsmith@example.com": "johnsmith@example.com"</code>
+ will add "By <a href="#">johnsmith@example.com</a>" to all issues and comments originally created by johnsmith@example.com.
+ By default, the email address or username is masked to ensure the user's privacy. Use this option if you want to show the full email address.
.form-group
.col-sm-12
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index 6978ad93024..ca58ae92d1b 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -6,4 +6,5 @@
Mime::Type.register_alias "text/plain", :diff
Mime::Type.register_alias "text/plain", :patch
-Mime::Type.register_alias 'text/html', :md
+Mime::Type.register_alias 'text/html', :markdown
+Mime::Type.register_alias 'text/html', :md
diff --git a/config/routes.rb b/config/routes.rb
index 4f33b11d220..744a99feded 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -39,9 +39,9 @@ Gitlab::Application.routes.draw do
# Help
get 'help' => 'help#index'
+ get 'help/:category/:file' => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ }
get 'help/shortcuts'
get 'help/ui' => 'help#ui'
- get 'help/:filepath' => 'help#show', as: :help_page, constraints: { filepath: /[^\.]+/ }
#
# Global snippets
diff --git a/doc/update/6.x-or-7.x-to-7.10.md b/doc/update/6.x-or-7.x-to-7.10.md
index 2ee9a07cee3..39e12f32d0e 100644
--- a/doc/update/6.x-or-7.x-to-7.10.md
+++ b/doc/update/6.x-or-7.x-to-7.10.md
@@ -126,7 +126,7 @@ sudo apt-get install nodejs
```bash
cd /home/git/gitlab-shell
sudo -u git -H git fetch
-sudo -u git -H git checkout v2.6.0
+sudo -u git -H git checkout v2.6.2
```
## 7. Install libs, migrations, etc.
diff --git a/features/steps/dashboard/help.rb b/features/steps/dashboard/help.rb
index fa52e391f05..ef433c57c6e 100644
--- a/features/steps/dashboard/help.rb
+++ b/features/steps/dashboard/help.rb
@@ -8,7 +8,7 @@ class Spinach::Features::DashboardHelp < Spinach::FeatureSteps
end
step 'I visit the "Rake Tasks" help page' do
- visit help_page_path('raketasks/maintenance', format: 'md')
+ visit help_page_path("raketasks", "maintenance")
end
step 'I should see "Rake Tasks" page markdown rendered' do
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index b5e82563ff1..70bfe059776 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -30,7 +30,10 @@ module Gitlab
def user_map
@user_map ||= begin
- user_map = Hash.new { |hash, user| Client.mask_email(user) }
+ user_map = Hash.new do |hash, user|
+ # Replace ... by \.\.\., so `johnsm...@gmail.com` isn't autolinked.
+ Client.mask_email(user).sub("...", "\\.\\.\\.")
+ end
import_data = project.import_data.try(:data)
stored_user_map = import_data["user_map"] if import_data
@@ -203,25 +206,25 @@ module Gitlab
end
def linkify_issues(s)
- s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2')
+ s = s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2')
+ s = s.gsub(/([Cc]omment) #([0-9]+)/, '\1 \2')
+ s
end
def escape_for_markdown(s)
- s = s.gsub("*", "\\*")
- s = s.gsub("#", "\\#")
+ # No headings and lists
+ s = s.gsub(/^#/, "\\#")
+ s = s.gsub(/^-/, "\\-")
+
+ # No inline code
s = s.gsub("`", "\\`")
- s = s.gsub(":", "\\:")
- s = s.gsub("-", "\\-")
- s = s.gsub("+", "\\+")
- s = s.gsub("_", "\\_")
- s = s.gsub("(", "\\(")
- s = s.gsub(")", "\\)")
- s = s.gsub("[", "\\[")
- s = s.gsub("]", "\\]")
- s = s.gsub("<", "\\<")
- s = s.gsub(">", "\\>")
+
+ # Carriage returns make me sad
s = s.gsub("\r", "")
+
+ # Markdown ignores single newlines, but we need them as <br />.
s = s.gsub("\n", " \n")
+
s
end
@@ -276,11 +279,18 @@ module Gitlab
if raw_updates.has_key?("blockedOn")
blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on|
name, id = raw_blocked_on.split(":", 2)
- if name == project.import_source
- "##{id}"
- else
- "#{project.namespace.path}/#{name}##{id}"
- end
+
+ deleted = name.start_with?("-")
+ name = name[1..-1] if deleted
+
+ text =
+ if name == project.import_source
+ "##{id}"
+ else
+ "#{project.namespace.path}/#{name}##{id}"
+ end
+ text = "~~#{text}~~" if deleted
+ text
end
updates << "*Blocked on: #{blocked_ons.join(", ")}*"
end
@@ -288,11 +298,18 @@ module Gitlab
if raw_updates.has_key?("blocking")
blockings = raw_updates["blocking"].map do |raw_blocked_on|
name, id = raw_blocked_on.split(":", 2)
- if name == project.import_source
- "##{id}"
- else
- "#{project.namespace.path}/#{name}##{id}"
- end
+
+ deleted = name.start_with?("-")
+ name = name[1..-1] if deleted
+
+ text =
+ if name == project.import_source
+ "##{id}"
+ else
+ "#{project.namespace.path}/#{name}##{id}"
+ end
+ text = "~~#{text}~~" if deleted
+ text
end
updates << "*Blocking: #{blockings.join(", ")}*"
end
@@ -340,7 +357,7 @@ module Gitlab
def format_issue_body(author, date, content, attachments)
body = []
- body << "*By #{author} on #{date}*"
+ body << "*By #{author} on #{date} (imported from Google Code)*"
body << "---"
if content.blank?
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
new file mode 100644
index 00000000000..93535ced7ae
--- /dev/null
+++ b/spec/controllers/help_controller_spec.rb
@@ -0,0 +1,61 @@
+require 'spec_helper'
+
+describe HelpController do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+ end
+
+ describe 'GET #show' do
+ context 'for Markdown formats' do
+ context 'when requested file exists' do
+ before do
+ get :show, category: 'ssh', file: 'README', format: :md
+ end
+
+ it 'assigns to @markdown' do
+ expect(assigns[:markdown]).not_to be_empty
+ end
+
+ it 'renders HTML' do
+ expect(response).to render_template('show.html.haml')
+ expect(response.content_type).to eq 'text/html'
+ end
+ end
+
+ context 'when requested file is missing' do
+ it 'renders not found' do
+ get :show, category: 'foo', file: 'bar', format: :md
+ expect(response).to be_not_found
+ end
+ end
+ end
+
+ context 'for image formats' do
+ context 'when requested file exists' do
+ it 'renders the raw file' do
+ get :show, category: 'workflow/protected_branches',
+ file: 'protected_branches1', format: :png
+ expect(response).to be_success
+ expect(response.content_type).to eq 'image/png'
+ expect(response.headers['Content-Disposition']).to match(/^inline;/)
+ end
+ end
+
+ context 'when requested file is missing' do
+ it 'renders not found' do
+ get :show, category: 'foo', file: 'bar', format: :png
+ expect(response).to be_not_found
+ end
+ end
+ end
+
+ context 'for other formats' do
+ it 'always renders not found' do
+ get :show, category: 'ssh', file: 'README', format: :foo
+ expect(response).to be_not_found
+ end
+ end
+ end
+end
diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb
index 28423eb8caa..8c6b669ce78 100644
--- a/spec/features/help_pages_spec.rb
+++ b/spec/features/help_pages_spec.rb
@@ -6,7 +6,7 @@ describe 'Help Pages', feature: true do
login_as :user
end
it 'replace the variable $your_email with the email of the user' do
- visit help_page_path(filepath: 'ssh/README', format: 'md')
+ visit help_page_path('ssh', 'README')
expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
end
end
diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb
index 1c4503ae0ef..67378328336 100644
--- a/spec/lib/gitlab/google_code_import/importer_spec.rb
+++ b/spec/lib/gitlab/google_code_import/importer_spec.rb
@@ -57,10 +57,11 @@ describe Gitlab::GoogleCodeImport::Importer do
expect(issue.label_names).to include("Type: Enhancement")
expect(issue.title).to eq("Scrolling through tasks")
expect(issue.state).to eq("closed")
- expect(issue.description).to include("schattenpr...")
+ expect(issue.description).to include("schattenpr\\.\\.\\.")
expect(issue.description).to include("November 18, 2009 00:20")
- expect(issue.description).to include('I like to scroll through the tasks with my scrollwheel \(like in fluxbox\).')
- expect(issue.description).to include('Patch is attached that adds two new mouse\-actions \(next\_taskprev\_task\)')
+ expect(issue.description).to include("Google Code")
+ expect(issue.description).to include('I like to scroll through the tasks with my scrollwheel (like in fluxbox).')
+ expect(issue.description).to include('Patch is attached that adds two new mouse-actions (next_task+prev_task)')
expect(issue.description).to include('that can be used for exactly that purpose.')
expect(issue.description).to include('all the best!')
expect(issue.description).to include('[tint2_task_scrolling.diff](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/tint2_task_scrolling.diff)')
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index f5db548f97c..e219a57c29e 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -64,50 +64,35 @@ describe SnippetsController, "routing" do
end
end
-# help GET /help(.:format) help#index
-# help_permissions GET /help/permissions(.:format) help#permissions
-# help_workflow GET /help/workflow(.:format) help#workflow
-# help_api GET /help/api(.:format) help#api
-# help_web_hooks GET /help/web_hooks(.:format) help#web_hooks
-# help_system_hooks GET /help/system_hooks(.:format) help#system_hooks
-# help_markdown GET /help/markdown(.:format) help#markdown
-# help_ssh GET /help/ssh(.:format) help#ssh
-# help_raketasks GET /help/raketasks(.:format) help#raketasks
-describe HelpController, 'routing' do
- it 'to #index' do
- expect(get('/help')).to route_to('help#index')
- end
-
- it 'to #permissions' do
- expect(get('/help/permissions/permissions')).to route_to('help#show', filepath: 'permissions/permissions')
- end
-
- it 'to #workflow' do
- expect(get('/help/workflow/README')).to route_to('help#show', filepath: 'workflow/README')
- end
-
- it 'to #api' do
- expect(get('/help/api/README')).to route_to('help#show', filepath: 'api/README')
- end
-
- it 'to #web_hooks' do
- expect(get('/help/web_hooks/web_hooks')).to route_to('help#show', filepath: 'web_hooks/web_hooks')
+# help GET /help(.:format) help#index
+# help_page GET /help/:category/:file(.:format) help#show {:category=>/.*/, :file=>/[^\/\.]+/}
+# help_shortcuts GET /help/shortcuts(.:format) help#shortcuts
+# help_ui GET /help/ui(.:format) help#ui
+describe HelpController, "routing" do
+ it "to #index" do
+ expect(get("/help")).to route_to('help#index')
end
- it 'to #system_hooks' do
- expect(get('/help/system_hooks/system_hooks')).to route_to('help#show', filepath: 'system_hooks/system_hooks')
- end
+ it 'to #show' do
+ path = '/help/markdown/markdown.md'
+ expect(get(path)).to route_to('help#show',
+ category: 'markdown',
+ file: 'markdown',
+ format: 'md')
- it 'to #markdown' do
- expect(get('/help/markdown/markdown')).to route_to('help#show',filepath: 'markdown/markdown')
+ path = '/help/workflow/protected_branches/protected_branches1.png'
+ expect(get(path)).to route_to('help#show',
+ category: 'workflow/protected_branches',
+ file: 'protected_branches1',
+ format: 'png')
end
- it 'to #ssh' do
- expect(get('/help/ssh/README')).to route_to('help#show', filepath: 'ssh/README')
+ it 'to #shortcuts' do
+ expect(get('/help/shortcuts')).to route_to('help#shortcuts')
end
- it 'to #raketasks' do
- expect(get('/help/raketasks/README')).to route_to('help#show', filepath: 'raketasks/README')
+ it 'to #ui' do
+ expect(get('/help/ui')).to route_to('help#ui')
end
end