From 5bbe2860bf3f9e24d2f658aa2a32baabbe997cea Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 20 Apr 2015 18:48:53 +0200 Subject: [PATCH 01/10] Update gitlab-grack to 2.0.1 to get unicorn to stop creating zombies. --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 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) From 6fb1e80a2622a13f316ec056fc7b17ebf79ef1ef Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 20 Apr 2015 11:05:51 -0700 Subject: [PATCH 02/10] Fix "Cannot move project" error message from popping up after a successful project transfer Multiple event handlers were firing, causing multiple form submissions. Closes #1448 and #1128 --- CHANGELOG | 2 +- app/assets/javascripts/application.js.coffee | 1 + app/assets/javascripts/confirm_danger_modal.js.coffee | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index be96d712439..9b7863826c0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.11.0 (unreleased) - Fix clone URL field and X11 Primary selection (Dmitry Medvinsky) - Ignore invalid lines in .gitmodules - - + - Fix "Cannot move project" error message from popping up after a successful transfer (Stan Hu) - - - diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index bd52d3d4d70..345af363775 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -173,6 +173,7 @@ $ -> $(@).closest(".diff-file").find(".notes_holder").toggle() e.preventDefault() + $(document).off "click", '.js-confirm-danger' $(document).on "click", '.js-confirm-danger', (e) -> e.preventDefault() btn = $(e.target) diff --git a/app/assets/javascripts/confirm_danger_modal.js.coffee b/app/assets/javascripts/confirm_danger_modal.js.coffee index bb99edbd09e..66e34dd4a08 100644 --- a/app/assets/javascripts/confirm_danger_modal.js.coffee +++ b/app/assets/javascripts/confirm_danger_modal.js.coffee @@ -8,11 +8,13 @@ class @ConfirmDangerModal submit = $('.js-confirm-danger-submit') submit.disable() + $('.js-confirm-danger-input').off 'input' $('.js-confirm-danger-input').on 'input', -> if rstrip($(@).val()) is project_path submit.enable() else submit.disable() + $('.js-confirm-danger-submit').off 'click' $('.js-confirm-danger-submit').on 'click', => @form.submit() From 355e6868a2bc8bee42fa5e070c14d2b00ec1fe81 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:30:07 +0200 Subject: [PATCH 03/10] Fix redirect when trying to view invalid Google Code import status. --- app/controllers/import/google_code_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 96c03199dddf36cbd0e2ad4089be535d73b26adc Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:30:23 +0200 Subject: [PATCH 04/10] Add "imported from Google Code" to imported issues. --- lib/gitlab/google_code_import/importer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index b5e82563ff1..5c7ac7fc4b7 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -340,7 +340,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? From c242ca9a177c0a101e2a02541830ffe56a1ae23e Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:31:15 +0200 Subject: [PATCH 05/10] Get imported links to render correctly by not escaping all special chars. --- lib/gitlab/google_code_import/importer.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 5c7ac7fc4b7..3916e51d0ab 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -207,21 +207,19 @@ module Gitlab 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
. s = s.gsub("\n", " \n") + s end From bc2dd5e772dea3ec78462441413842f9fe82165a Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:31:50 +0200 Subject: [PATCH 06/10] Import "Comment #10" as "Comment 10" to not incorrectly reference issue. --- lib/gitlab/google_code_import/importer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 3916e51d0ab..caa57f557c0 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -203,7 +203,9 @@ 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) From 18f80c55600e485c87d23afccd82b4947e27ff17 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:32:29 +0200 Subject: [PATCH 07/10] Fix rendering of deleted blocking/blocked-on statuses. --- lib/gitlab/google_code_import/importer.rb | 34 ++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index caa57f557c0..532689bca6c 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -276,11 +276,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 +295,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 From 1c30f775995378082942f4c7c8c2f7bdc11e48a9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:32:48 +0200 Subject: [PATCH 08/10] Don't autolink masked imported email addresses. --- lib/gitlab/google_code_import/importer.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 532689bca6c..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 From 1419e94816396d699777ab220e3625429bd40b68 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:33:04 +0200 Subject: [PATCH 09/10] Improve description of Google Code import user map. --- .../import/google_code/new_user_map.html.haml | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) 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. "johnsmith@gmail.com": "John Smith" or "johnsmith@gmail.com": "@johnsmith". 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 :. 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 + "johnsmith@example.com": "johnsm...@example.com" + 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 + "johnsmith@example.com": "@johnsmith" + will add "By @johnsmith" to all issues and comments originally created by johnsmith@example.com, + and will set @johnsmith as the assignee on all issues originally assigned to johnsmith@example.com. + %li + %strong Map a Google Code user to a full name + %p + "johnsmith@example.com": "John Smith" + 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 + "johnsmith@example.com": "johnsmith@example.com" + will add "By johnsmith@example.com" 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 From 0c650dc0e2d030b6cfd39bbe25f88c5e349f5c70 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:35:53 +0200 Subject: [PATCH 10/10] Update Google Code importer test. --- spec/lib/gitlab/google_code_import/importer_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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)')