summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG23
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock10
-rw-r--r--app/assets/stylesheets/pages/notes.scss4
-rw-r--r--app/controllers/import/bitbucket_controller.rb1
-rw-r--r--app/controllers/projects/network_controller.rb4
-rw-r--r--app/helpers/blob_helper.rb8
-rw-r--r--app/helpers/emails_helper.rb4
-rw-r--r--app/models/group.rb6
-rw-r--r--app/models/project.rb11
-rw-r--r--app/views/devise/sessions/_new_base.html.haml2
-rw-r--r--app/views/profiles/keys/_form.html.haml7
-rw-r--r--app/views/projects/network/show.html.haml6
-rw-r--r--app/views/projects/wikis/show.html.haml6
-rw-r--r--doc/gitlab-basics/README.md4
-rw-r--r--doc/gitlab-basics/add-file.md31
-rw-r--r--doc/integration/twitter.md12
-rw-r--r--doc/ssh/README.md3
-rw-r--r--doc/workflow/gitlab_flow.md8
-rw-r--r--doc/workflow/importing/README.md5
-rw-r--r--doc/workflow/labels.md4
-rw-r--r--features/project/network_graph.feature5
-rw-r--r--features/steps/project/network_graph.rb14
-rw-r--r--lib/api/entities.rb10
-rw-r--r--lib/backup/database.rb7
-rw-r--r--lib/backup/manager.rb2
-rw-r--r--lib/backup/repository.rb5
-rw-r--r--lib/backup/uploads.rb6
-rw-r--r--lib/gitlab/backend/grack_auth.rb11
-rw-r--r--lib/gitlab/backend/shell_env.rb11
-rw-r--r--lib/gitlab/bitbucket_import/client.rb21
-rw-r--r--lib/gitlab/markdown/relative_link_filter.rb14
-rw-r--r--lib/redcarpet/render/gitlab_html.rb8
-rw-r--r--lib/rouge/formatters/html_gitlab.rb176
-rw-r--r--lib/support/nginx/gitlab25
-rw-r--r--lib/support/nginx/gitlab-ssl25
-rw-r--r--lib/tasks/gitlab/check.rake8
-rw-r--r--lib/tasks/gitlab/import.rake4
-rw-r--r--spec/features/markdown_spec.rb427
-rw-r--r--spec/features/security/group_access_spec.rb30
-rw-r--r--spec/fixtures/markdown.md.erb13
-rw-r--r--spec/helpers/blob_helper_spec.rb18
-rw-r--r--spec/lib/gitlab/markdown/relative_link_filter_spec.rb16
-rw-r--r--spec/models/project_spec.rb18
-rw-r--r--spec/services/projects/fork_service_spec.rb2
-rw-r--r--spec/support/markdown_feature.rb106
-rw-r--r--spec/support/matchers/markdown_matchers.rb156
47 files changed, 889 insertions, 411 deletions
diff --git a/CHANGELOG b/CHANGELOG
index cf0fa36bd47..27cf89b5938 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,10 +1,13 @@
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
+ - Fix multi-line syntax highlighting (Stan Hu)
+ - Fix network graph when branch name has single quotes (Stan Hu)
+ - Upgrade gitlab_git to version 7.2.6 to fix Error 500 when creating network graphs (Stan Hu)
+ - Add support for Unicode filenames in relative links (Hiroyuki Sato)
- Fix URL used for refreshing notes if relative_url is present (Bartłomiej Święcki)
- Fix commit data retrieval when branch name has single quotes (Stan Hu)
- - Fix Error 500 when browsing projects with no HEAD (Stan Hu)
- - Add rake task 'gitlab:update_commit_count' (Daniel Gerhardt)
+ - Check that project was actually created rather than just validated in import:repos task (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)
- Fix the "Reload with full diff" URL button (Stan Hu)
@@ -16,6 +19,20 @@ v 7.14.0 (unreleased)
- Expire Rails cache entries after two weeks to prevent endless Redis growth
- Add support for destroying project milestones (Stan Hu)
- Add fetch command to the MR page
+ - Add project star and fork count, group avatar URL and user/group web URL attributes to API
+ - Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
+ - Add fetch command to the MR page.
+ - Disabled autocapitalize and autocorrect on login field (Daryl Chan)
+
+v 7.13.2
+ - Fix randomly failed spec
+ - Create project services on Project creation
+ - Add admin_merge_request ability to Developer level and up
+ - Fix Error 500 when browsing projects with no HEAD (Stan Hu)
+ - Fix labels / assignee / milestone for the merge requests when issues are disabled
+ - Show the first tab automatically on MergeRequests#new
+ - Add rake task 'gitlab:update_commit_count' (Daniel Gerhardt)
+ - Fix Gmail Actions
v 7.13.1
- Fix: Label modifications are not reflected in existing notes and in the issue list
@@ -26,10 +43,10 @@ v 7.13.1
- Fix: ActionView::Template::Error
- Fix: "Create Merge Request" isn't always shown in event for newly pushed branch
- Fix bug causing "Remove source-branch" option not to work for merge requests from the same project.
+ - Render Note field hints consistently for "new" and "edit" forms
v 7.13.0
- Remove repository graph log to fix slow cache updates after push event (Stan Hu)
-v 7.13.0 (unreleased)
- Return comments in created order in merge request API (Stan Hu)
- Only enable HSTS header for HTTPS and port 443 (Stan Hu)
- Fix user autocomplete for unauthenticated users accessing public projects (Stan Hu)
diff --git a/Gemfile b/Gemfile
index ba32feba3e7..1c49a603798 100644
--- a/Gemfile
+++ b/Gemfile
@@ -38,7 +38,7 @@ gem "browser", '~> 0.8.0'
# Extracting information from a git repository
# Provide access to Gitlab::Git library
-gem "gitlab_git", '~> 7.2.5'
+gem "gitlab_git", '~> 7.2.6'
# Ruby/Rack Git Smart-HTTP Server Handler
# GitLab fork with a lot of changes (improved thread-safety, better memory usage etc)
@@ -272,4 +272,3 @@ end
gem "newrelic_rpm"
gem 'octokit', '3.7.0'
-gem "rugments", "~> 1.0.0.beta8"
diff --git a/Gemfile.lock b/Gemfile.lock
index 6e571072a4c..44365017edc 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -271,7 +271,7 @@ GEM
mime-types (~> 1.19)
gitlab_emoji (0.1.0)
gemojione (~> 2.0)
- gitlab_git (7.2.5)
+ gitlab_git (7.2.6)
activesupport (~> 4.0)
charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0)
@@ -288,7 +288,7 @@ GEM
github-markup (~> 1.3.1)
gollum-grit_adapter (~> 0.1, >= 0.1.1)
nokogiri (~> 1.6.4)
- rouge (~> 1.7.4)
+ rouge (~> 1.9)
sanitize (~> 2.1.0)
stringex (~> 2.5.1)
gon (5.0.1)
@@ -536,7 +536,7 @@ GEM
netrc (~> 0.7)
rinku (1.7.3)
rotp (1.6.1)
- rouge (1.7.7)
+ rouge (1.9.1)
rqrcode (0.4.2)
rqrcode-rails3 (0.1.7)
rqrcode (>= 0.4.2)
@@ -579,7 +579,6 @@ GEM
rubyntlm (0.5.0)
rubypants (0.2.0)
rugged (0.22.2)
- rugments (1.0.0.beta8)
safe_yaml (1.0.4)
sanitize (2.1.0)
nokogiri (>= 1.4.4)
@@ -784,7 +783,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.2)
gitlab-linguist (~> 3.0.1)
gitlab_emoji (~> 0.1)
- gitlab_git (~> 7.2.5)
+ gitlab_git (~> 7.2.6)
gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.2.1)
gollum-lib (~> 4.0.2)
@@ -836,7 +835,6 @@ DEPENDENCIES
rqrcode-rails3
rspec-rails (~> 3.3.0)
rubocop (= 0.28.0)
- rugments (~> 1.0.0.beta8)
sanitize (~> 2.0)
sass-rails (~> 4.0.5)
sdoc
diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss
index 4da65b28743..85c828ec1ad 100644
--- a/app/assets/stylesheets/pages/notes.scss
+++ b/app/assets/stylesheets/pages/notes.scss
@@ -37,7 +37,7 @@ ul.notes {
font-size: 13px;
a {
- @extend .cgray;
+ @extend .cgray;
&:hover {
text-decoration: underline;
@@ -105,6 +105,8 @@ ul.notes {
}
hr {
+ // Darken 'whitesmoke' a bit to make it more visible in note bodies
+ border-color: darken(#F5F5F5, 8%);
margin: 10px 0;
}
}
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index ca78a4aaa8e..af0b841f0b7 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -3,6 +3,7 @@ class Import::BitbucketController < Import::BaseController
before_action :bitbucket_auth, except: :callback
rescue_from OAuth::Error, with: :bitbucket_unauthorized
+ rescue_from Gitlab::BitbucketImport::Client::Unauthorized, with: :bitbucket_unauthorized
def callback
request_token = session.delete(:oauth_request_token)
diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb
index 06aef91cadd..b181c47baec 100644
--- a/app/controllers/projects/network_controller.rb
+++ b/app/controllers/projects/network_controller.rb
@@ -7,6 +7,10 @@ class Projects::NetworkController < Projects::ApplicationController
before_action :authorize_download_code!
def show
+
+ @url = namespace_project_network_path(@project.namespace, @project, @ref, @options.merge(format: :json))
+ @commit_url = namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")
+
respond_to do |format|
format.html
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 50df3801703..77d99140c43 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -1,6 +1,6 @@
module BlobHelper
def highlight(blob_name, blob_content, nowrap: false, continue: false)
- @formatter ||= Rugments::Formatters::HTML.new(
+ @formatter ||= Rouge::Formatters::HTMLGitlab.new(
nowrap: nowrap,
cssclass: 'code highlight',
lineanchors: true,
@@ -8,11 +8,11 @@ module BlobHelper
)
begin
- @lexer ||= Rugments::Lexer.guess(filename: blob_name, source: blob_content).new
+ @lexer ||= Rouge::Lexer.guess(filename: blob_name, source: blob_content).new
result = @formatter.format(@lexer.lex(blob_content, continue: continue)).html_safe
rescue
- lexer = Rugments::Lexers::PlainText
- result = @formatter.format(lexer.lex(blob_content)).html_safe
+ @lexer = Rouge::Lexers::PlainText
+ result = @formatter.format(@lexer.lex(blob_content)).html_safe
end
result
diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb
index 128de18bc47..45788ba95ac 100644
--- a/app/helpers/emails_helper.rb
+++ b/app/helpers/emails_helper.rb
@@ -31,8 +31,8 @@ module EmailsHelper
end
def color_email_diff(diffcontent)
- formatter = Rugments::Formatters::HTML.new(cssclass: "highlight", inline_theme: :github)
- lexer = Rugments::Lexers::Diff.new
+ formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', inline_theme: 'github')
+ lexer = Rouge::Lexers::Diff
raw formatter.format(lexer.lex(diffcontent))
end
diff --git a/app/models/group.rb b/app/models/group.rb
index 051c672cb33..cfb8faa1491 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -56,6 +56,12 @@ class Group < Namespace
name
end
+ def avatar_url(size = nil)
+ if avatar.present?
+ [gitlab_config.url, avatar.url].join
+ end
+ end
+
def owners
@owners ||= group_members.owners.map(&:user)
end
diff --git a/app/models/project.rb b/app/models/project.rb
index ff372ea9aa5..0921fdfe9b4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -36,7 +36,6 @@ class Project < ActiveRecord::Base
include Gitlab::ConfigHelper
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
- include Rails.application.routes.url_helpers
include Referable
include Sortable
@@ -316,7 +315,7 @@ class Project < ActiveRecord::Base
end
def web_url
- [gitlab_config.url, path_with_namespace].join('/')
+ Rails.application.routes.url_helpers.namespace_project_url(self.namespace, self)
end
def web_url_without_protocol
@@ -433,7 +432,7 @@ class Project < ActiveRecord::Base
if avatar.present?
[gitlab_config.url, avatar.url].join
elsif avatar_in_git
- [gitlab_config.url, namespace_project_avatar_path(namespace, self)].join
+ Rails.application.routes.url_helpers.namespace_project_avatar_url(namespace, self)
end
end
@@ -571,7 +570,7 @@ class Project < ActiveRecord::Base
end
def http_url_to_repo
- [gitlab_config.url, '/', path_with_namespace, '.git'].join('')
+ "#{web_url}.git"
end
# Check if current branch name is marked as protected in the system
@@ -705,14 +704,14 @@ class Project < ActiveRecord::Base
ensure_satellite_exists
true
else
- errors.add(:base, 'Failed to fork repository')
+ errors.add(:base, 'Failed to fork repository via gitlab-shell')
false
end
else
if gitlab_shell.add_repository(path_with_namespace)
true
else
- errors.add(:base, 'Failed to create repository')
+ errors.add(:base, 'Failed to create repository via gitlab-shell')
false
end
end
diff --git a/app/views/devise/sessions/_new_base.html.haml b/app/views/devise/sessions/_new_base.html.haml
index 54a39726771..9f5520603cd 100644
--- a/app/views/devise/sessions/_new_base.html.haml
+++ b/app/views/devise/sessions/_new_base.html.haml
@@ -1,5 +1,5 @@
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
- = f.text_field :login, class: "form-control top", placeholder: "Username or Email", autofocus: "autofocus"
+ = f.text_field :login, class: "form-control top", placeholder: "Username or Email", autofocus: "autofocus", autocapitalize: "off", autocorrect: "off"
= f.password_field :password, class: "form-control bottom", placeholder: "Password"
- if devise_mapping.rememberable?
.remember-me.checkbox
diff --git a/app/views/profiles/keys/_form.html.haml b/app/views/profiles/keys/_form.html.haml
index f905417f0e2..b76a5b636ac 100644
--- a/app/views/profiles/keys/_form.html.haml
+++ b/app/views/profiles/keys/_form.html.haml
@@ -7,13 +7,12 @@
%li= msg
.form-group
- = f.label :title, class: 'control-label'
- .col-sm-10= f.text_field :title, class: "form-control"
- .form-group
= f.label :key, class: 'control-label'
.col-sm-10
= f.text_area :key, class: "form-control", rows: 8
-
+ .form-group
+ = f.label :title, class: 'control-label'
+ .col-sm-10= f.text_field :title, class: "form-control"
.form-actions
= f.submit 'Add key', class: "btn btn-create"
diff --git a/app/views/projects/network/show.html.haml b/app/views/projects/network/show.html.haml
index a88cf167511..52b5b8b877e 100644
--- a/app/views/projects/network/show.html.haml
+++ b/app/views/projects/network/show.html.haml
@@ -17,9 +17,9 @@
:javascript
network_graph = new Network({
- url: '#{namespace_project_network_path(@project.namespace, @project, @ref, @options.merge(format: :json))}',
- commit_url: '#{namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")}',
- ref: '#{@ref}',
+ url: "#{escape_javascript(@url)}",
+ commit_url: "#{escape_javascript(@commit_url)}",
+ ref: "#{escape_javascript(@ref)}",
commit_id: '#{@commit.id}'
})
new ShortcutsNetwork(network_graph.branch_graph)
diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml
index 83cd4c66672..5c4dd7f91ae 100644
--- a/app/views/projects/wikis/show.html.haml
+++ b/app/views/projects/wikis/show.html.haml
@@ -3,6 +3,10 @@
%h3.page-title
= @page.title
= render 'main_links'
+
+.wiki-last-edit-by
+ Last edited by #{@page.commit.author.name} #{time_ago_with_tooltip(@page.commit.authored_date)}
+
- if @page.historical?
.warning_message
This is an old version of this page.
@@ -16,6 +20,6 @@
= render_wiki_content(@page)
%hr
-
.wiki-last-edit-by
Last edited by #{@page.commit.author.name} #{time_ago_with_tooltip(@page.commit.authored_date)}
+
diff --git a/doc/gitlab-basics/README.md b/doc/gitlab-basics/README.md
index d6272cd5912..538894f5848 100644
--- a/doc/gitlab-basics/README.md
+++ b/doc/gitlab-basics/README.md
@@ -2,7 +2,7 @@
Step-by-step guides on the basics of working with Git and GitLab.
-* [Start using Git on the commandline](start-using-git.md)
+* [Start using Git on the command line](start-using-git.md)
* [Create and add your SSH Keys](create-your-ssh-keys.md)
@@ -17,3 +17,5 @@ Step-by-step guides on the basics of working with Git and GitLab.
* [Create a branch](create-branch.md)
* [Fork a project](fork-project.md)
+
+* [Add a file](add-file.md)
diff --git a/doc/gitlab-basics/add-file.md b/doc/gitlab-basics/add-file.md
new file mode 100644
index 00000000000..e7c441e7698
--- /dev/null
+++ b/doc/gitlab-basics/add-file.md
@@ -0,0 +1,31 @@
+# How to add a file
+
+You can create a file in your [shell](command-line-commands.md) or in GitLab.
+
+To create a file in GitLab, sign in to [GitLab.com](https://gitlab.com).
+
+Select a project on the right side of your screen:
+
+![Select a project](basicsimages/select_project.png)
+
+It's a good idea to [create a branch](create-branch.md), but it's not necessary.
+
+Go to the directory where you'd like to add the file and click on the "+" sign next to the name of the project and directory:
+
+![Create a file](basicsimages/create_file.png)
+
+Name your file (you can't add spaces, so you can use hyphens or underscores). Don't forget to include the markup language you'd like to use :
+
+![File name](basicsimages/file_name.png)
+
+Add all the information that you'd like to include in your file:
+
+![Add information](basicsimages/white_space.png)
+
+Add a commit message based on what you just added and then click on "commit changes":
+
+![Commit changes](basicsimages/commit_changes.png)
+
+### Note
+Besides its regular files, every directory needs a README.md or README.html file which works like an index, telling
+what the directory is about. It's the first document you'll find when you open a directory.
diff --git a/doc/integration/twitter.md b/doc/integration/twitter.md
index fe9091ad9a8..1350c8f693c 100644
--- a/doc/integration/twitter.md
+++ b/doc/integration/twitter.md
@@ -2,9 +2,7 @@
To enable the Twitter OmniAuth provider you must register your application with Twitter. Twitter will generate a client ID and secret key for you to use.
-1. Sign in to [Twitter Developers](https://dev.twitter.com/) area.
-
-1. Hover over the avatar in the top right corner and select "My applications."
+1. Sign in to [Twitter Application Management](https://apps.twitter.com/).
1. Select "Create new app"
@@ -14,18 +12,18 @@ To enable the Twitter OmniAuth provider you must register your application with
- Description: Create a description.
- Website: The URL to your GitLab installation. 'https://gitlab.example.com'
- Callback URL: 'https://gitlab.example.com/users/auth/twitter/callback'
- - Agree to the "Rules of the Road."
+ - Agree to the "Developer Agreement".
![Twitter App Details](twitter_app_details.png)
1. Select "Create your Twitter application."
1. Select the "Settings" tab.
-1. Underneath the Callback URL check the box next to "Allow this application to be used to Sign in the Twitter."
+1. Underneath the Callback URL check the box next to "Allow this application to be used to Sign in with Twitter."
1. Select "Update settings" at the bottom to save changes.
-1. Select the "API Keys" tab.
+1. Select the "Keys and Access Tokens" tab.
1. You should now see an API key and API secret (see screenshot). Keep this page open as you continue configuration.
@@ -78,4 +76,4 @@ To enable the Twitter OmniAuth provider you must register your application with
1. Restart GitLab for the changes to take effect.
-On the sign in page there should now be a Twitter icon below the regular sign in form. Click the icon to begin the authentication process. Twitter will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in.
+On the sign in page there should now be a Twitter icon below the regular sign in form. Click the icon to begin the authentication process. Twitter will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in. \ No newline at end of file
diff --git a/doc/ssh/README.md b/doc/ssh/README.md
index 5f44f9351dd..7cdcd11c04c 100644
--- a/doc/ssh/README.md
+++ b/doc/ssh/README.md
@@ -105,3 +105,6 @@ IdentityFile ~/my-ssh-key-directory/company-com-private-key-filename
Note in the gitlab.com example above a username was specified to override the default chosen by OpenSSH (your local username). This is only required if your local and remote usernames differ.
Due to the wide variety of SSH clients and their very large number of configuration options, further explanation of these topics is beyond the scope of this document.
+
+Public SSH keys need to be unique, as they will bind to your account. Your SSH key is the only identifier you'll
+have when pushing code via SSH. That's why it needs to uniquely map to a single user.
diff --git a/doc/workflow/gitlab_flow.md b/doc/workflow/gitlab_flow.md
index 0e87dc74217..f608674faf6 100644
--- a/doc/workflow/gitlab_flow.md
+++ b/doc/workflow/gitlab_flow.md
@@ -31,7 +31,7 @@ We think there is still room for improvement and will detail a set of practices
## Git flow and its problems
-[![Git Flow timeline by Vincent Driessen, used with permission](gitdashflow.png)
+![Git Flow timeline by Vincent Driessen, used with permission](gitdashflow.png)
Git flow was one of the first proposals to use git branches and it has gotten a lot of attention.
It advocates a master branch and a separate develop branch as well as supporting branches for features, releases and hotfixes.
@@ -54,7 +54,7 @@ And doing releases doesn't automatically mean also doing hotfixes.
![Master branch with feature branches merged in](github_flow.png)
- In reaction to git flow a simpler alternative was detailed, [GitHub flow](https://guides.github.com/introduction/flow/index.html).
+In reaction to git flow a simpler alternative was detailed, [GitHub flow](https://guides.github.com/introduction/flow/index.html).
This flow has only feature branches and a master branch.
This is very simple and clean, many organizations have adopted it with great success.
Atlassian recommends [a similar strategy](http://blogs.atlassian.com/2014/01/simple-git-workflow-simple/) although they rebase feature branches.
@@ -131,7 +131,7 @@ When you feel comfortable with it to be merged you assign it to the person that
There is room for more feedback and after the assigned person feels comfortable with the result the branch is merged.
If the assigned person does not feel comfortable they can close the merge request without merging.
-In GitLab it is common to protect the long-lived branches (e.g. the master branch) so that normal developers [can't modify these protected branches](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/permissions/permissions.md).
+In GitLab it is common to protect the long-lived branches (e.g. the master branch) so that normal developers [can't modify these protected branches](http://doc.gitlab.com/ce/permissions/permissions.html).
So if you want to merge it into a protected branch you assign it to someone with master authorizations.
## Issues with GitLab flow
@@ -216,7 +216,7 @@ This prevents creating a merge commit when merging master into your feature bran
However, just like with squashing you should never rebase commits you have pushed to a remote server.
This makes it impossible to rebase work in progress that you already shared with your team which is something we recommend.
When using rebase to keep your feature branch updated you [need to resolve similar conflicts again and again](http://blogs.atlassian.com/2013/10/git-team-workflows-merge-or-rebase/).
-You can reuse recorded resolutions (rerere) sometimes, but with without rebasing you only have to solve the conflicts one time and you’re set.
+You can reuse recorded resolutions (rerere) sometimes, but without rebasing you only have to solve the conflicts one time and you’re set.
There has to be a better way to avoid many merge commits.
The way to prevent creating many merge commits is to not frequently merge master into the feature branch.
diff --git a/doc/workflow/importing/README.md b/doc/workflow/importing/README.md
index 19395657719..cd98d1b9852 100644
--- a/doc/workflow/importing/README.md
+++ b/doc/workflow/importing/README.md
@@ -6,4 +6,7 @@
4. [SVN](migrating_from_svn.md)
### Note
-* If you'd like to migrate from a self-hosted GitLab instance to GitLab.com, you can copy your repos by changing the remote and pushing to the new server; but issues and merge requests can't be imported. \ No newline at end of file
+* If you'd like to migrate from a self-hosted GitLab instance to GitLab.com, you can copy your repos by changing the remote and pushing to the new server; but issues and merge requests can't be imported.
+
+* Repositories are imported to GitLab via HTTP.
+If the repository is too large, it can timeout. We have a soft limit of 10GB.
diff --git a/doc/workflow/labels.md b/doc/workflow/labels.md
index 085b7baf5ce..6e4840ca5ae 100644
--- a/doc/workflow/labels.md
+++ b/doc/workflow/labels.md
@@ -1,6 +1,6 @@
# Labels
-In GitLab, you can easily tag issues and merge requests. If you have permission level `Developer` or higher, you can manage labels. To create, edit or delete a label, go to a project and then to `Issues` and then `Labels`.
+In GitLab, you can easily tag issues and Merge Requests. If you have permission level `Developer` or higher, you can manage labels. To create, edit or delete a label, go to a project and then to `Issues` and then `Labels`.
Here you can create a new label.
@@ -14,3 +14,5 @@ If you want to change an existing label, press edit next to the listed label.
You will be presented with the same form as when creating a new label.
![edit label](labels/label3.png)
+
+You can add labels to Merge Requests when you create or edit them.
diff --git a/features/project/network_graph.feature b/features/project/network_graph.feature
index 8beb6043aff..6cc89a15a78 100644
--- a/features/project/network_graph.feature
+++ b/features/project/network_graph.feature
@@ -11,6 +11,11 @@ Feature: Project Network Graph
And page should have "master" on graph
@javascript
+ Scenario: I should see project network with 'test' branch
+ When I visit project network page on branch 'test'
+ Then page should have 'test' on graph
+
+ @javascript
Scenario: I should switch "branch" and "tag"
When I switch ref to "feature"
Then page should select "feature" in select box
diff --git a/features/steps/project/network_graph.rb b/features/steps/project/network_graph.rb
index 992cf2734fd..7a83d32a240 100644
--- a/features/steps/project/network_graph.rb
+++ b/features/steps/project/network_graph.rb
@@ -11,8 +11,12 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network::Graph.stub(max_count: 10)
- project = Project.find_by(name: "Shop")
- visit namespace_project_network_path(project.namespace, project, "master")
+ @project = Project.find_by(name: "Shop")
+ visit namespace_project_network_path(@project.namespace, @project, "master")
+ end
+
+ step "I visit project network page on branch 'test'" do
+ visit namespace_project_network_path(@project.namespace, @project, "'test'")
end
step 'page should select "master" in select box' do
@@ -29,6 +33,12 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
end
end
+ step "page should have 'test' on graph" do
+ page.within '.network-graph' do
+ expect(page).to have_content "'test'"
+ end
+ end
+
When 'I switch ref to "feature"' do
select 'feature', from: 'ref'
sleep 2
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index ecf1412dee5..dcfd7a8e1a7 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -6,6 +6,10 @@ module API
class UserBasic < UserSafe
expose :id, :state, :avatar_url
+
+ expose :web_url do |user, options|
+ Rails.application.routes.url_helpers.user_url(user)
+ end
end
class User < UserBasic
@@ -59,6 +63,7 @@ module API
expose :namespace
expose :forked_from_project, using: Entities::ForkedFromProject, if: lambda{ | project, options | project.forked? }
expose :avatar_url
+ expose :star_count, :forks_count
end
class ProjectMember < UserBasic
@@ -69,6 +74,11 @@ module API
class Group < Grape::Entity
expose :id, :name, :path, :description
+ expose :avatar_url
+
+ expose :web_url do |group, options|
+ Rails.application.routes.url_helpers.group_url(group)
+ end
end
class GroupDetail < Group
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index c5a5396cbbf..bbb230a10f0 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -7,7 +7,11 @@ module Backup
def initialize
@config = YAML.load_file(File.join(Rails.root,'config','database.yml'))[Rails.env]
@db_dir = File.join(Gitlab.config.backup.path, 'db')
- FileUtils.mkdir_p(@db_dir) unless Dir.exists?(@db_dir)
+ FileUtils.rm_rf(@db_dir)
+ # Ensure the parent dir of @db_dir exists
+ FileUtils.mkdir_p(Gitlab.config.backup.path)
+ # Fail if somebody raced to create @db_dir before us
+ FileUtils.mkdir(@db_dir, mode: 0700)
end
def dump
@@ -25,7 +29,6 @@ module Backup
abort 'Backup failed' unless success
$progress.print 'Compressing database ... '
- FileUtils.rm_f db_file_name_gz
success = system('gzip', db_file_name)
report_success(success)
abort 'Backup failed: compress error' unless success
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 6fa2079d1a8..9ae4b346436 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -16,8 +16,6 @@ module Backup
file << s.to_yaml.gsub(/^---\n/,'')
end
- FileUtils.chmod(0700, folders_to_backup)
-
# create archive
$progress.print "Creating backup archive: #{tar_file} ... "
orig_umask = File.umask(0077)
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index dfb2da9f84e..4d70f7883dd 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -130,7 +130,10 @@ module Backup
def prepare
FileUtils.rm_rf(backup_repos_path)
- FileUtils.mkdir_p(backup_repos_path)
+ # Ensure the parent dir of backup_repos_path exists
+ FileUtils.mkdir_p(Gitlab.config.backup.path)
+ # Fail if somebody raced to create backup_repos_path before us
+ FileUtils.mkdir(backup_repos_path, mode: 0700)
end
def silent
diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb
index bf43610acf6..1f9626644e6 100644
--- a/lib/backup/uploads.rb
+++ b/lib/backup/uploads.rb
@@ -10,7 +10,11 @@ module Backup
# Copy uploads from public/uploads to backup/uploads
def dump
- FileUtils.mkdir_p(backup_uploads_dir)
+ FileUtils.rm_rf(backup_uploads_dir)
+ # Ensure the parent dir of backup_uploads_dir exists
+ FileUtils.mkdir_p(Gitlab.config.backup.path)
+ # Fail if somebody raced to create backup_uploads_dir before us
+ FileUtils.mkdir(backup_uploads_dir, mode: 0700)
FileUtils.cp_r(app_uploads_dir, backup_dir)
end
diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb
index 03cef30c97d..12292f614e9 100644
--- a/lib/gitlab/backend/grack_auth.rb
+++ b/lib/gitlab/backend/grack_auth.rb
@@ -26,7 +26,12 @@ module Grack
auth!
if project && authorized_request?
- @app.call(env)
+ if ENV['GITLAB_GRACK_AUTH_ONLY'] == '1'
+ # Tell gitlab-git-http-server the request is OK, and what the GL_ID is
+ render_grack_auth_ok
+ else
+ @app.call(env)
+ end
elsif @user.nil? && !@gitlab_ci
unauthorized
else
@@ -174,6 +179,10 @@ module Grack
end
end
+ def render_grack_auth_ok
+ [200, { "Content-Type" => "application/json" }, [JSON.dump({ 'GL_ID' => Gitlab::ShellEnv.gl_id(@user) })]]
+ end
+
def render_not_found
[404, { "Content-Type" => "text/plain" }, ["Not Found"]]
end
diff --git a/lib/gitlab/backend/shell_env.rb b/lib/gitlab/backend/shell_env.rb
index 17ec029eed4..9f5adee594a 100644
--- a/lib/gitlab/backend/shell_env.rb
+++ b/lib/gitlab/backend/shell_env.rb
@@ -7,7 +7,7 @@ module Gitlab
def set_env(user)
# Set GL_ID env variable
if user
- ENV['GL_ID'] = "user-#{user.id}"
+ ENV['GL_ID'] = gl_id(user)
end
end
@@ -15,5 +15,14 @@ module Gitlab
# Reset GL_ID env variable
ENV['GL_ID'] = nil
end
+
+ def gl_id(user)
+ if user.present?
+ "user-#{user.id}"
+ else
+ # This empty string is used in the render_grack_auth_ok method
+ ""
+ end
+ end
end
end
diff --git a/lib/gitlab/bitbucket_import/client.rb b/lib/gitlab/bitbucket_import/client.rb
index 5b1952b9675..778b76f6890 100644
--- a/lib/gitlab/bitbucket_import/client.rb
+++ b/lib/gitlab/bitbucket_import/client.rb
@@ -1,6 +1,8 @@
module Gitlab
module BitbucketImport
class Client
+ class Unauthorized < StandardError; end
+
attr_reader :consumer, :api
def initialize(access_token = nil, access_token_secret = nil)
@@ -46,23 +48,23 @@ module Gitlab
end
def user
- JSON.parse(api.get("/api/1.0/user").body)
+ JSON.parse(get("/api/1.0/user").body)
end
def issues(project_identifier)
- JSON.parse(api.get("/api/1.0/repositories/#{project_identifier}/issues").body)
+ JSON.parse(get("/api/1.0/repositories/#{project_identifier}/issues").body)
end
def issue_comments(project_identifier, issue_id)
- JSON.parse(api.get("/api/1.0/repositories/#{project_identifier}/issues/#{issue_id}/comments").body)
+ JSON.parse(get("/api/1.0/repositories/#{project_identifier}/issues/#{issue_id}/comments").body)
end
def project(project_identifier)
- JSON.parse(api.get("/api/1.0/repositories/#{project_identifier}").body)
+ JSON.parse(get("/api/1.0/repositories/#{project_identifier}").body)
end
def find_deploy_key(project_identifier, key)
- JSON.parse(api.get("/api/1.0/repositories/#{project_identifier}/deploy-keys").body).find do |deploy_key|
+ JSON.parse(get("/api/1.0/repositories/#{project_identifier}/deploy-keys").body).find do |deploy_key|
deploy_key["key"].chomp == key.chomp
end
end
@@ -82,11 +84,18 @@ module Gitlab
end
def projects
- JSON.parse(api.get("/api/1.0/user/repositories").body).select { |repo| repo["scm"] == "git" }
+ JSON.parse(get("/api/1.0/user/repositories").body).select { |repo| repo["scm"] == "git" }
end
private
+ def get(url)
+ response = api.get(url)
+ raise Unauthorized if (400..499).include?(response.code.to_i)
+
+ response
+ end
+
def config
Gitlab.config.omniauth.providers.find { |provider| provider.name == "bitbucket"}
end
diff --git a/lib/gitlab/markdown/relative_link_filter.rb b/lib/gitlab/markdown/relative_link_filter.rb
index 9de2b24a9da..30f50b82996 100644
--- a/lib/gitlab/markdown/relative_link_filter.rb
+++ b/lib/gitlab/markdown/relative_link_filter.rb
@@ -98,15 +98,25 @@ module Gitlab
#
# Returns a String
def path_type(path)
- if repository.tree(current_sha, path).entries.any?
+ unescaped_path = Addressable::URI.unescape(path)
+
+ if tree?(unescaped_path)
'tree'
- elsif repository.blob_at(current_sha, path).try(:image?)
+ elsif image?(unescaped_path)
'raw'
else
'blob'
end
end
+ def tree?(path)
+ repository.tree(current_sha, path).entries.any?
+ end
+
+ def image?(path)
+ repository.blob_at(current_sha, path).try(:image?)
+ end
+
def current_sha
context[:commit].try(:id) ||
ref ? repository.commit(ref).try(:sha) : repository.head_commit.sha
diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb
index 2f7aff03c2a..04440e4f68d 100644
--- a/lib/redcarpet/render/gitlab_html.rb
+++ b/lib/redcarpet/render/gitlab_html.rb
@@ -22,10 +22,10 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
ERB::Util.html_escape_once(text)
end
- # Stolen from Rugments::Plugins::Redcarpet as this module is not required
- # from Rugments's gem root.
+ # Stolen from Rouge::Plugins::Redcarpet as this module is not required
+ # from Rouge's gem root.
def block_code(code, language)
- lexer = Rugments::Lexer.find_fancy(language, code) || Rugments::Lexers::PlainText
+ lexer = Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText
# XXX HACK: Redcarpet strips hard tabs out of code blocks,
# so we assume you're not using leading spaces that aren't tabs,
@@ -34,7 +34,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
code.gsub!(/^ /, "\t")
end
- formatter = Rugments::Formatters::HTML.new(
+ formatter = Rouge::Formatters::HTMLGitlab.new(
cssclass: "code highlight #{@color_scheme} #{lexer.tag}"
)
formatter.format(lexer.lex(code))
diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb
new file mode 100644
index 00000000000..092a920a0c4
--- /dev/null
+++ b/lib/rouge/formatters/html_gitlab.rb
@@ -0,0 +1,176 @@
+require 'cgi'
+
+module Rouge
+ module Formatters
+ class HTMLGitlab < Rouge::Formatter
+ tag 'html_gitlab'
+
+ # Creates a new <tt>Rouge::Formatter::HTMLGitlab</tt> instance.
+ #
+ # [+nowrap+] If set to True, don't wrap the output at all, not
+ # even inside a <tt><pre></tt> tag (default: false).
+ # [+cssclass+] CSS class for the wrapping <tt><div></tt> tag
+ # (default: 'highlight').
+ # [+linenos+] If set to 'table', output line numbers as a table
+ # with two cells, one containing the line numbers,
+ # the other the whole code. This is copy paste friendly,
+ # but may cause alignment problems with some browsers
+ # or fonts. If set to 'inline', the line numbers will
+ # be integrated in the <tt><pre></tt> tag that contains
+ # the code (default: nil).
+ # [+linenostart+] The line number for the first line (default: 1).
+ # [+lineanchors+] If set to true the formatter will wrap each output
+ # line in an anchor tag with a name of L-linenumber.
+ # This allows easy linking to certain lines
+ # (default: false).
+ # [+lineanchorsid+] If lineanchors is true the name of the anchors can
+ # be changed with lineanchorsid to e.g. foo-linenumber
+ # (default: 'L').
+ # [+anchorlinenos+] If set to true, will wrap line numbers in <tt><a></tt>
+ # tags. Used in combination with linenos and lineanchors
+ # (default: false).
+ # [+inline_theme+] Inline CSS styles for the <pre> tag (default: false).
+ def initialize(
+ nowrap: false,
+ cssclass: 'highlight',
+ linenos: nil,
+ linenostart: 1,
+ lineanchors: false,
+ lineanchorsid: 'L',
+ anchorlinenos: false,
+ inline_theme: nil
+ )
+ @nowrap = nowrap
+ @cssclass = cssclass
+ @linenos = linenos
+ @linenostart = linenostart
+ @lineanchors = lineanchors
+ @lineanchorsid = lineanchorsid
+ @anchorlinenos = anchorlinenos
+ @inline_theme = Theme.find(@inline_theme).new if @inline_theme.is_a?(String)
+ end
+
+ def render(tokens)
+ case @linenos
+ when 'table'
+ render_tableized(tokens)
+ when 'inline'
+ render_untableized(tokens)
+ else
+ render_untableized(tokens)
+ end
+ end
+
+ alias_method :format, :render
+
+ private
+
+ def render_untableized(tokens)
+ data = process_tokens(tokens)
+
+ html = ''
+ html << "<pre class=\"#{@cssclass}\"><code>" unless @nowrap
+ html << wrap_lines(data[:code])
+ html << "</code></pre>\n" unless @nowrap
+ html
+ end
+
+ def render_tableized(tokens)
+ data = process_tokens(tokens)
+
+ html = ''
+ html << "<div class=\"#{@cssclass}\">" unless @nowrap
+ html << '<table><tbody>'
+ html << "<td class=\"linenos\"><pre>"
+ html << wrap_linenos(data[:numbers])
+ html << '</pre></td>'
+ html << "<td class=\"lines\"><pre><code>"
+ html << wrap_lines(data[:code])
+ html << '</code></pre></td>'
+ html << '</tbody></table>'
+ html << '</div>' unless @nowrap
+ html
+ end
+
+ def process_tokens(tokens)
+ num_lines = 0
+ last_val = ''
+ rendered = ''
+
+ tokens.each do |tok, val|
+ last_val = val
+ num_lines += val.scan(/\n/).size
+ rendered << span(tok, val)
+ end
+
+ numbers = (@linenostart..num_lines + @linenostart - 1).to_a
+
+ { numbers: numbers, code: rendered }
+ end
+
+ def wrap_linenos(numbers)
+ if @anchorlinenos
+ numbers.map! do |number|
+ "<a href=\"##{@lineanchorsid}#{number}\">#{number}</a>"
+ end
+ end
+ numbers.join("\n")
+ end
+
+ def wrap_lines(rendered)
+ if @lineanchors
+ lines = rendered.split("\n")
+ lines = lines.each_with_index.map do |line, index|
+ number = index + @linenostart
+
+ if @linenos == 'inline'
+ "<a name=\"L#{number}\"></a>" \
+ "<span class=\"linenos\">#{number}</span>" \
+ "<span id=\"#{@lineanchorsid}#{number}\" class=\"line\">#{line}" \
+ '</span>'
+ else
+ "<span id=\"#{@lineanchorsid}#{number}\" class=\"line\">#{line}" \
+ '</span>'
+ end
+ end
+ lines.join("\n")
+ else
+ if @linenos == 'inline'
+ lines = rendered.split("\n")
+ lines = lines.each_with_index.map do |line, index|
+ number = index + @linenostart
+ "<span class=\"linenos\">#{number}</span>#{line}"
+ end
+ lines.join("\n")
+ else
+ rendered
+ end
+ end
+ end
+
+ def wrap_values(val, element)
+ lines = val.split("\n")
+ lines = lines.map{ |x| "<span #{element}>#{x}</span>" }
+ lines.join("\n")
+ end
+
+ def span(tok, val)
+ # http://stackoverflow.com/a/1600584/2587286
+ val = CGI.escapeHTML(val)
+
+ if tok.shortname.empty?
+ val
+ else
+ # In the case of multi-line values (e.g. comments), we need to apply
+ # styling to each line since span elements are inline.
+ if @inline_theme
+ rules = @inline_theme.style_for(tok).rendered_rules
+ wrap_values(val, "style=\"#{rules.to_a.join(';')}\"")
+ else
+ wrap_values(val, "class=\"#{tok.shortname}\"")
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab
index edb987875df..efa0898900f 100644
--- a/lib/support/nginx/gitlab
+++ b/lib/support/nginx/gitlab
@@ -38,6 +38,11 @@ upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}
+## Experimental: gitlab-git-http-server
+# upstream gitlab-git-http-server {
+# server localhost:8181;
+# }
+
## Normal HTTP host
server {
## Either remove "default_server" from the listen line below,
@@ -109,6 +114,26 @@ server {
proxy_pass http://gitlab;
}
+ ## Experimental: send Git HTTP traffic to gitlab-git-http-server instead of Unicorn
+ # location ~ [-\/\w\.]+\.git\/ {
+ # ## If you use HTTPS make sure you disable gzip compression
+ # ## to be safe against BREACH attack.
+ # # gzip off;
+
+ # ## https://github.com/gitlabhq/gitlabhq/issues/694
+ # ## Some requests take more than 30 seconds.
+ # proxy_read_timeout 300;
+ # proxy_connect_timeout 300;
+ # proxy_redirect off;
+
+ # proxy_set_header Host $http_host;
+ # proxy_set_header X-Real-IP $remote_addr;
+ # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ # proxy_set_header X-Forwarded-Proto $scheme;
+
+ # proxy_pass http://gitlab-git-http-server;
+ # }
+
## Enable gzip compression as per rails guide:
## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
## WARNING: If you are using relative urls remove the block below
diff --git a/lib/support/nginx/gitlab-ssl b/lib/support/nginx/gitlab-ssl
index 766559b49f6..314525518f1 100644
--- a/lib/support/nginx/gitlab-ssl
+++ b/lib/support/nginx/gitlab-ssl
@@ -42,6 +42,11 @@ upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}
+## Experimental: gitlab-git-http-server
+# upstream gitlab-git-http-server {
+# server localhost:8181;
+# }
+
## Redirects all HTTP traffic to the HTTPS host
server {
## Either remove "default_server" from the listen line below,
@@ -156,6 +161,26 @@ server {
proxy_pass http://gitlab;
}
+ ## Experimental: send Git HTTP traffic to gitlab-git-http-server instead of Unicorn
+ # location ~ [-\/\w\.]+\.git\/ {
+ # ## If you use HTTPS make sure you disable gzip compression
+ # ## to be safe against BREACH attack.
+ # gzip off;
+
+ # ## https://github.com/gitlabhq/gitlabhq/issues/694
+ # ## Some requests take more than 30 seconds.
+ # proxy_read_timeout 300;
+ # proxy_connect_timeout 300;
+ # proxy_redirect off;
+
+ # proxy_set_header Host $http_host;
+ # proxy_set_header X-Real-IP $remote_addr;
+ # proxy_set_header X-Forwarded-Ssl on;
+ # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ # proxy_set_header X-Forwarded-Proto $scheme;
+ # proxy_pass http://gitlab-git-http-server;
+ # }
+
## Enable gzip compression as per rails guide:
## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
## WARNING: If you are using relative urls remove the block below
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index aed84226a2f..badb47c6779 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -485,7 +485,8 @@ namespace :gitlab do
if project.empty_repo?
puts "repository is empty".magenta
- elsif File.realpath(project_hook_directory) == File.realpath(gitlab_shell_hooks_path)
+ elsif File.directory?(project_hook_directory) && File.directory?(gitlab_shell_hooks_path) &&
+ (File.realpath(project_hook_directory) == File.realpath(gitlab_shell_hooks_path))
puts 'ok'.green
else
puts "wrong or missing hooks".red
@@ -754,7 +755,7 @@ namespace :gitlab do
print "Ruby version >= #{required_version} ? ... "
if current_version.valid? && required_version <= current_version
- puts "yes (#{current_version})".green
+ puts "yes (#{current_version})".green
else
puts "no".red
try_fixing_it(
@@ -772,7 +773,7 @@ namespace :gitlab do
print "Git version >= #{required_version} ? ... "
if current_version.valid? && required_version <= current_version
- puts "yes (#{current_version})".green
+ puts "yes (#{current_version})".green
else
puts "no".red
try_fixing_it(
@@ -806,4 +807,3 @@ namespace :gitlab do
end
end
end
-
diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake
index 5f83e5e8e7f..c1ee271ae2b 100644
--- a/lib/tasks/gitlab/import.rake
+++ b/lib/tasks/gitlab/import.rake
@@ -62,11 +62,11 @@ namespace :gitlab do
project = Projects::CreateService.new(user, project_params).execute
- if project.valid?
+ if project.persisted?
puts " * Created #{project.name} (#{repo_path})".green
else
puts " * Failed trying to create #{project.name} (#{repo_path})".red
- puts " Validation Errors: #{project.errors.messages}".red
+ puts " Errors: #{project.errors.messages}".red
end
end
end
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb
index b8199aa5e61..859a62f740f 100644
--- a/spec/features/markdown_spec.rb
+++ b/spec/features/markdown_spec.rb
@@ -17,410 +17,215 @@ require 'erb'
# -> Post-process HTML
# -> `gfm_with_options` helper
# -> HTML::Pipeline
-# -> Sanitize
-# -> RelativeLink
-# -> Emoji
-# -> Table of Contents
-# -> Autolinks
-# -> Rinku (http, https, ftp)
-# -> Other schemes
-# -> ExternalLink
-# -> References
-# -> TaskList
+# -> SanitizationFilter
+# -> Other filters, depending on pipeline
# -> `html_safe`
# -> Template
#
# See the MarkdownFeature class for setup details.
describe 'GitLab Markdown', feature: true do
- include ActionView::Helpers::TagHelper
- include ActionView::Helpers::UrlHelper
include Capybara::Node::Matchers
include GitlabMarkdownHelper
+ include MarkdownMatchers
- # `markdown` calls these two methods
- def current_user
- @feat.user
- end
-
- def user_color_scheme_class
- :white
- end
-
- # Let's only parse this thing once
- before(:all) do
- @feat = MarkdownFeature.new
-
- # `markdown` expects a `@project` variable
- @project = @feat.project
-
- @md = markdown(@feat.raw_markdown)
- @doc = Nokogiri::HTML::DocumentFragment.parse(@md)
- end
-
- after(:all) do
- @feat.teardown
+ # Sometimes it can be useful to see the parsed output of the Markdown document
+ # for debugging. Call this method to write the output to
+ # `tmp/capybara/<filename>.html`.
+ def write_markdown(filename = 'markdown_spec')
+ File.open(Rails.root.join("tmp/capybara/#{filename}.html"), 'w') do |file|
+ file.puts @html
+ end
end
- # Given a header ID, goes to that element's parent (the header itself), then
- # its next sibling element (the body).
- def get_section(id)
- @doc.at_css("##{id}").parent.next_element
+ def doc(html = @html)
+ Nokogiri::HTML::DocumentFragment.parse(html)
end
- # Sometimes it can be useful to see the parsed output of the Markdown document
- # for debugging. Uncomment this block to write the output to
- # tmp/capybara/markdown_spec.html.
- #
- # it 'writes to a file' do
- # File.open(Rails.root.join('tmp/capybara/markdown_spec.html'), 'w') do |file|
- # file.puts @md
- # end
- # end
-
- describe 'Markdown' do
- describe 'No Intra Emphasis' do
+ # Shared behavior that all pipelines should exhibit
+ shared_examples 'all pipelines' do
+ describe 'Redcarpet extensions' do
it 'does not parse emphasis inside of words' do
- body = get_section('no-intra-emphasis')
- expect(body.to_html).not_to match('foo<em>bar</em>baz')
+ expect(doc.to_html).not_to match('foo<em>bar</em>baz')
end
- end
- describe 'Tables' do
it 'parses table Markdown' do
- body = get_section('tables')
- expect(body).to have_selector('th:contains("Header")')
- expect(body).to have_selector('th:contains("Row")')
- expect(body).to have_selector('th:contains("Example")')
+ aggregate_failures do
+ expect(doc).to have_selector('th:contains("Header")')
+ expect(doc).to have_selector('th:contains("Row")')
+ expect(doc).to have_selector('th:contains("Example")')
+ end
end
it 'allows Markdown in tables' do
- expect(@doc.at_css('td:contains("Baz")').children.to_html).
+ expect(doc.at_css('td:contains("Baz")').children.to_html).
to eq '<strong>Baz</strong>'
end
- end
- describe 'Fenced Code Blocks' do
it 'parses fenced code blocks' do
- expect(@doc).to have_selector('pre.code.highlight.white.c')
- expect(@doc).to have_selector('pre.code.highlight.white.python')
+ aggregate_failures do
+ expect(doc).to have_selector('pre.code.highlight.white.c')
+ expect(doc).to have_selector('pre.code.highlight.white.python')
+ end
end
- end
- describe 'Strikethrough' do
it 'parses strikethroughs' do
- expect(@doc).to have_selector(%{del:contains("and this text doesn't")})
+ expect(doc).to have_selector(%{del:contains("and this text doesn't")})
end
- end
- describe 'Superscript' do
it 'parses superscript' do
- body = get_section('superscript')
- expect(body.to_html).to match('1<sup>st</sup>')
- expect(body.to_html).to match('2<sup>nd</sup>')
+ expect(doc).to have_selector('sup', count: 2)
end
end
- end
- describe 'HTML::Pipeline' do
describe 'SanitizationFilter' do
- it 'uses a permissive whitelist' do
- expect(@doc).to have_selector('b:contains("b tag")')
- expect(@doc).to have_selector('em:contains("em tag")')
- expect(@doc).to have_selector('code:contains("code tag")')
- expect(@doc).to have_selector('kbd:contains("s")')
- expect(@doc).to have_selector('strike:contains(Emoji)')
- expect(@doc).to have_selector('img[src*="smile.png"]')
- expect(@doc).to have_selector('br')
- expect(@doc).to have_selector('hr')
+ it 'permits b elements' do
+ expect(doc).to have_selector('b:contains("b tag")')
end
- it 'permits span elements' do
- expect(@doc).to have_selector('span:contains("span tag")')
+ it 'permits em elements' do
+ expect(doc).to have_selector('em:contains("em tag")')
end
- it 'permits table alignment' do
- expect(@doc.at_css('th:contains("Header")')['style']).to eq 'text-align: center'
- expect(@doc.at_css('th:contains("Row")')['style']).to eq 'text-align: right'
- expect(@doc.at_css('th:contains("Example")')['style']).to eq 'text-align: left'
-
- expect(@doc.at_css('td:contains("Foo")')['style']).to eq 'text-align: center'
- expect(@doc.at_css('td:contains("Bar")')['style']).to eq 'text-align: right'
- expect(@doc.at_css('td:contains("Baz")')['style']).to eq 'text-align: left'
+ it 'permits code elements' do
+ expect(doc).to have_selector('code:contains("code tag")')
end
- it 'removes `rel` attribute from links' do
- body = get_section('sanitizationfilter')
- expect(body).not_to have_selector('a[rel="bookmark"]')
+ it 'permits kbd elements' do
+ expect(doc).to have_selector('kbd:contains("s")')
end
- it "removes `href` from `a` elements if it's fishy" do
- expect(@doc).not_to have_selector('a[href*="javascript"]')
+ it 'permits strike elements' do
+ expect(doc).to have_selector('strike:contains(Emoji)')
end
- end
- describe 'Escaping' do
- let(:table) { @doc.css('table').last.at_css('tbody') }
-
- it 'escapes non-tag angle brackets' do
- expect(table.at_xpath('.//tr[1]/td[3]').inner_html).to eq '1 &lt; 3 &amp; 5'
+ it 'permits img elements' do
+ expect(doc).to have_selector('img[src*="smile.png"]')
end
- end
-
- describe 'Edge Cases' do
- it 'allows markup inside link elements' do
- expect(@doc.at_css('a[href="#link-emphasis"]').to_html).
- to eq %{<a href="#link-emphasis"><em>text</em></a>}
-
- expect(@doc.at_css('a[href="#link-strong"]').to_html).
- to eq %{<a href="#link-strong"><strong>text</strong></a>}
- expect(@doc.at_css('a[href="#link-code"]').to_html).
- to eq %{<a href="#link-code"><code>text</code></a>}
+ it 'permits br elements' do
+ expect(doc).to have_selector('br')
end
- end
- describe 'EmojiFilter' do
- it 'parses Emoji' do
- expect(@doc).to have_selector('img.emoji', count: 10)
+ it 'permits hr elements' do
+ expect(doc).to have_selector('hr')
end
- end
- describe 'TableOfContentsFilter' do
- it 'creates anchors inside header elements' do
- expect(@doc).to have_selector('h1 a#gitlab-markdown')
- expect(@doc).to have_selector('h2 a#markdown')
- expect(@doc).to have_selector('h3 a#autolinkfilter')
+ it 'permits span elements' do
+ expect(doc).to have_selector('span:contains("span tag")')
end
- end
- describe 'AutolinkFilter' do
- let(:list) { get_section('autolinkfilter').next_element }
-
- def item(index)
- list.at_css("li:nth-child(#{index})")
+ it 'permits style attribute in th elements' do
+ aggregate_failures do
+ expect(doc.at_css('th:contains("Header")')['style']).to eq 'text-align: center'
+ expect(doc.at_css('th:contains("Row")')['style']).to eq 'text-align: right'
+ expect(doc.at_css('th:contains("Example")')['style']).to eq 'text-align: left'
+ end
end
- it 'autolinks http://' do
- expect(item(1).children.first.name).to eq 'a'
- expect(item(1).children.first['href']).to eq 'http://about.gitlab.com/'
+ it 'permits style attribute in td elements' do
+ aggregate_failures do
+ expect(doc.at_css('td:contains("Foo")')['style']).to eq 'text-align: center'
+ expect(doc.at_css('td:contains("Bar")')['style']).to eq 'text-align: right'
+ expect(doc.at_css('td:contains("Baz")')['style']).to eq 'text-align: left'
+ end
end
- it 'autolinks https://' do
- expect(item(2).children.first.name).to eq 'a'
- expect(item(2).children.first['href']).to eq 'https://google.com/'
+ it 'removes `rel` attribute from links' do
+ expect(doc).not_to have_selector('a[rel="bookmark"]')
end
- it 'autolinks ftp://' do
- expect(item(3).children.first.name).to eq 'a'
- expect(item(3).children.first['href']).to eq 'ftp://ftp.us.debian.org/debian/'
+ it "removes `href` from `a` elements if it's fishy" do
+ expect(doc).not_to have_selector('a[href*="javascript"]')
end
+ end
- it 'autolinks smb://' do
- expect(item(4).children.first.name).to eq 'a'
- expect(item(4).children.first['href']).to eq 'smb://foo/bar/baz'
+ describe 'Escaping' do
+ it 'escapes non-tag angle brackets' do
+ table = doc.css('table').last.at_css('tbody')
+ expect(table.at_xpath('.//tr[1]/td[3]').inner_html).to eq '1 &lt; 3 &amp; 5'
end
+ end
- it 'autolinks irc://' do
- expect(item(5).children.first.name).to eq 'a'
- expect(item(5).children.first['href']).to eq 'irc://irc.freenode.net/git'
- end
+ describe 'Edge Cases' do
+ it 'allows markup inside link elements' do
+ aggregate_failures do
+ expect(doc.at_css('a[href="#link-emphasis"]').to_html).
+ to eq %{<a href="#link-emphasis"><em>text</em></a>}
- it 'autolinks short, invalid URLs' do
- expect(item(6).children.first.name).to eq 'a'
- expect(item(6).children.first['href']).to eq 'http://localhost:3000'
- end
+ expect(doc.at_css('a[href="#link-strong"]').to_html).
+ to eq %{<a href="#link-strong"><strong>text</strong></a>}
- %w(code a kbd).each do |elem|
- it "ignores links inside '#{elem}' element" do
- body = get_section('autolinkfilter')
- expect(body).not_to have_selector("#{elem} a")
+ expect(doc.at_css('a[href="#link-code"]').to_html).
+ to eq %{<a href="#link-code"><code>text</code></a>}
end
end
end
describe 'ExternalLinkFilter' do
- let(:links) { get_section('externallinkfilter').next_element }
-
it 'adds nofollow to external link' do
- expect(links.css('a').first.to_html).to match 'nofollow'
+ link = doc.at_css('a:contains("Google")')
+ expect(link.attr('rel')).to match 'nofollow'
end
it 'ignores internal link' do
- expect(links.css('a').last.to_html).not_to match 'nofollow'
+ link = doc.at_css('a:contains("GitLab Root")')
+ expect(link.attr('rel')).not_to match 'nofollow'
end
end
+ end
- describe 'ReferenceFilter' do
- it 'handles references in headers' do
- header = @doc.at_css('#reference-filters-eg-1').parent
-
- expect(header.css('a').size).to eq 2
- end
-
- it "handles references in Markdown" do
- body = get_section('reference-filters-eg-1')
- expect(body).to have_selector('em a.gfm-merge_request', count: 1)
- end
-
- it 'parses user references' do
- body = get_section('userreferencefilter')
- expect(body).to have_selector('a.gfm.gfm-project_member', count: 3)
- end
-
- it 'parses issue references' do
- body = get_section('issuereferencefilter')
- expect(body).to have_selector('a.gfm.gfm-issue', count: 2)
- end
-
- it 'parses merge request references' do
- body = get_section('mergerequestreferencefilter')
- expect(body).to have_selector('a.gfm.gfm-merge_request', count: 2)
- end
+ context 'default pipeline' do
+ before(:all) do
+ @feat = MarkdownFeature.new
- it 'parses snippet references' do
- body = get_section('snippetreferencefilter')
- expect(body).to have_selector('a.gfm.gfm-snippet', count: 2)
- end
+ # `gfm_with_options` depends on a `@project` variable
+ @project = @feat.project
- it 'parses commit range references' do
- body = get_section('commitrangereferencefilter')
- expect(body).to have_selector('a.gfm.gfm-commit_range', count: 2)
- end
+ @html = markdown(@feat.raw_markdown)
+ end
- it 'parses commit references' do
- body = get_section('commitreferencefilter')
- expect(body).to have_selector('a.gfm.gfm-commit', count: 2)
- end
+ it_behaves_like 'all pipelines'
- it 'parses label references' do
- body = get_section('labelreferencefilter')
- expect(body).to have_selector('a.gfm.gfm-label', count: 3)
- end
+ it 'includes RelativeLinkFilter' do
+ expect(doc).to parse_relative_links
end
- describe 'Task Lists' do
- it 'generates task lists' do
- body = get_section('task-lists')
- expect(body).to have_selector('ul.task-list', count: 2)
- expect(body).to have_selector('li.task-list-item', count: 7)
- expect(body).to have_selector('input[checked]', count: 3)
- end
+ it 'includes EmojiFilter' do
+ expect(doc).to parse_emoji
end
- end
-end
-
-# This is a helper class used by the GitLab Markdown feature spec
-#
-# Because the feature spec only cares about the output of the Markdown, and the
-# test setup and teardown and parsing is fairly expensive, we only want to do it
-# once. Unfortunately RSpec will not let you access `let`s in a `before(:all)`
-# block, so we fake it by encapsulating all the shared setup in this class.
-#
-# The class renders `spec/fixtures/markdown.md.erb` using ERB, allowing for
-# reference to the factory-created objects.
-class MarkdownFeature
- include FactoryGirl::Syntax::Methods
-
- def initialize
- DatabaseCleaner.start
- end
-
- def teardown
- DatabaseCleaner.clean
- end
-
- def user
- @user ||= create(:user)
- end
- def group
- unless @group
- @group = create(:group)
- @group.add_user(user, Gitlab::Access::DEVELOPER)
+ it 'includes TableOfContentsFilter' do
+ expect(doc).to create_header_links
end
- @group
- end
-
- # Direct references ----------------------------------------------------------
-
- def project
- @project ||= create(:project)
- end
-
- def issue
- @issue ||= create(:issue, project: project)
- end
-
- def merge_request
- @merge_request ||= create(:merge_request, :simple, source_project: project)
- end
-
- def snippet
- @snippet ||= create(:project_snippet, project: project)
- end
-
- def commit
- @commit ||= project.commit
- end
-
- def commit_range
- unless @commit_range
- commit2 = project.commit('HEAD~3')
- @commit_range = CommitRange.new("#{commit.id}...#{commit2.id}", project)
+ it 'includes AutolinkFilter' do
+ expect(doc).to create_autolinks
end
- @commit_range
- end
-
- def simple_label
- @simple_label ||= create(:label, name: 'gfm', project: project)
- end
-
- def label
- @label ||= create(:label, name: 'awaiting feedback', project: project)
- end
-
- # Cross-references -----------------------------------------------------------
-
- def xproject
- unless @xproject
- namespace = create(:namespace, name: 'cross-reference')
- @xproject = create(:project, namespace: namespace)
- @xproject.team << [user, :developer]
+ it 'includes all reference filters' do
+ aggregate_failures do
+ expect(doc).to reference_users
+ expect(doc).to reference_issues
+ expect(doc).to reference_merge_requests
+ expect(doc).to reference_snippets
+ expect(doc).to reference_commit_ranges
+ expect(doc).to reference_commits
+ expect(doc).to reference_labels
+ end
end
- @xproject
- end
-
- def xissue
- @xissue ||= create(:issue, project: xproject)
- end
-
- def xmerge_request
- @xmerge_request ||= create(:merge_request, :simple, source_project: xproject)
- end
-
- def xsnippet
- @xsnippet ||= create(:project_snippet, project: xproject)
- end
-
- def xcommit
- @xcommit ||= xproject.commit
- end
-
- def xcommit_range
- unless @xcommit_range
- xcommit2 = xproject.commit('HEAD~2')
- @xcommit_range = CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject)
+ it 'includes TaskListFilter' do
+ expect(doc).to parse_task_lists
end
+ end
- @xcommit_range
+ # `markdown` calls these two methods
+ def current_user
+ @feat.user
end
- def raw_markdown
- fixture = Rails.root.join('spec/fixtures/markdown.md.erb')
- ERB.new(File.read(fixture)).result(binding)
+ def user_color_scheme_class
+ :white
end
end
diff --git a/spec/features/security/group_access_spec.rb b/spec/features/security/group_access_spec.rb
index 0f36e474989..8ce15388605 100644
--- a/spec/features/security/group_access_spec.rb
+++ b/spec/features/security/group_access_spec.rb
@@ -36,7 +36,7 @@ describe 'Group access', feature: true do
subject { group_path(group) }
context 'with public projects' do
- before(:all) { create_project(:public) }
+ let!(:project) { create_project(:public) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -48,7 +48,7 @@ describe 'Group access', feature: true do
end
context 'with mixed projects' do
- before(:all) { create_project(:mixed) }
+ let!(:project) { create_project(:mixed) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -60,7 +60,7 @@ describe 'Group access', feature: true do
end
context 'with internal projects' do
- before(:all) { create_project(:internal) }
+ let!(:project) { create_project(:internal) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -86,7 +86,7 @@ describe 'Group access', feature: true do
subject { issues_group_path(group) }
context 'with public projects' do
- before(:all) { create_project(:public) }
+ let!(:project) { create_project(:public) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -98,7 +98,7 @@ describe 'Group access', feature: true do
end
context 'with mixed projects' do
- before(:all) { create_project(:mixed) }
+ let!(:project) { create_project(:mixed) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -110,7 +110,7 @@ describe 'Group access', feature: true do
end
context 'with internal projects' do
- before(:all) { create_project(:internal) }
+ let!(:project) { create_project(:internal) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -136,7 +136,7 @@ describe 'Group access', feature: true do
subject { merge_requests_group_path(group) }
context 'with public projects' do
- before(:all) { create_project(:public) }
+ let!(:project) { create_project(:public) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -148,7 +148,7 @@ describe 'Group access', feature: true do
end
context 'with mixed projects' do
- before(:all) { create_project(:mixed) }
+ let!(:project) { create_project(:mixed) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -160,7 +160,7 @@ describe 'Group access', feature: true do
end
context 'with internal projects' do
- before(:all) { create_project(:internal) }
+ let!(:project) { create_project(:internal) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -186,7 +186,7 @@ describe 'Group access', feature: true do
subject { group_group_members_path(group) }
context 'with public projects' do
- before(:all) { create_project(:public) }
+ let!(:project) { create_project(:public) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -198,7 +198,7 @@ describe 'Group access', feature: true do
end
context 'with mixed projects' do
- before(:all) { create_project(:mixed) }
+ let!(:project) { create_project(:mixed) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -210,7 +210,7 @@ describe 'Group access', feature: true do
end
context 'with internal projects' do
- before(:all) { create_project(:internal) }
+ let!(:project) { create_project(:internal) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_allowed_for group_member(:master) }
@@ -236,7 +236,7 @@ describe 'Group access', feature: true do
subject { edit_group_path(group) }
context 'with public projects' do
- before(:all) { create_project(:public) }
+ let!(:project) { create_project(:public) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_denied_for group_member(:master) }
@@ -248,7 +248,7 @@ describe 'Group access', feature: true do
end
context 'with mixed projects' do
- before(:all) { create_project(:mixed) }
+ let!(:project) { create_project(:mixed) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_denied_for group_member(:master) }
@@ -260,7 +260,7 @@ describe 'Group access', feature: true do
end
context 'with internal projects' do
- before(:all) { create_project(:internal) }
+ let!(:project) { create_project(:internal) }
it { is_expected.to be_allowed_for group_member(:owner) }
it { is_expected.to be_denied_for group_member(:master) }
diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb
index 02ab46c905a..41d12afa9ce 100644
--- a/spec/fixtures/markdown.md.erb
+++ b/spec/fixtures/markdown.md.erb
@@ -100,6 +100,13 @@ Markdown should be usable inside a link. Let's try!
- [**text**](#link-strong)
- [`text`](#link-code)
+### RelativeLinkFilter
+
+Linking to a file relative to this project's repository should work.
+
+[Relative Link](doc/README.md)
+![Relative Image](app/assets/images/touch-icon-ipad.png)
+
### EmojiFilter
Because life would be :zzz: without Emoji, right? :rocket:
@@ -123,9 +130,9 @@ These are all plain text that should get turned into links:
But it shouldn't autolink text inside certain tags:
-- <code>http://about.gitlab.com/</code>
-- <a>http://about.gitlab.com/</a>
-- <kbd>http://about.gitlab.com/</kbd>
+- <code>http://code.gitlab.com/</code>
+- <a>http://a.gitlab.com/</a>
+- <kbd>http://kbd.gitlab.com/</kbd>
### ExternalLinkFilter
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index e49e4e6d5d8..76009c36099 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -6,6 +6,14 @@ describe BlobHelper do
let(:no_context_content) { ":type \"assem\"))" }
let(:blob_content) { "(make-pathname :defaults name\n#{no_context_content}" }
let(:split_content) { blob_content.split("\n") }
+ let(:multiline_content) do
+ %q(
+ def test(input):
+ """This is line 1 of a multi-line comment.
+ This is line 2.
+ """
+ )
+ end
it 'should return plaintext for unknown lexer context' do
result = highlight(blob_name, no_context_content, nowrap: true, continue: false)
@@ -29,5 +37,15 @@ describe BlobHelper do
result = split_content.map{ |content| highlight(blob_name, content, nowrap: true, continue: true) }
expect(result).to eq(expected)
end
+
+ it 'should highlight multi-line comments' do
+ result = highlight(blob_name, multiline_content, nowrap: true, continue: false)
+ html = Nokogiri::HTML(result)
+ lines = html.search('.s')
+ expect(lines.count).to eq(3)
+ expect(lines[0].text).to eq('"""This is line 1 of a multi-line comment.')
+ expect(lines[1].text).to eq(' This is line 2.')
+ expect(lines[2].text).to eq(' """')
+ end
end
end
diff --git a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
index 5ee5310825d..7f4d67e403f 100644
--- a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
@@ -1,3 +1,5 @@
+# encoding: UTF-8
+
require 'spec_helper'
module Gitlab::Markdown
@@ -101,6 +103,20 @@ module Gitlab::Markdown
expect(doc.at_css('a')['href']).to eq 'http://example.com'
end
+ it 'supports Unicode filenames' do
+ path = 'files/images/한글.png'
+ escaped = Addressable::URI.escape(path)
+
+ # Stub these methods so the file doesn't actually need to be in the repo
+ allow_any_instance_of(described_class).to receive(:file_exists?).
+ and_return(true)
+ allow_any_instance_of(described_class).
+ to receive(:image?).with(path).and_return(true)
+
+ doc = filter(image(escaped))
+ expect(doc.at_css('img')['src']).to match '/raw/'
+ end
+
context 'when requested path is a file in the repo' do
let(:requested_path) { 'doc/api/README.md' }
include_examples :relative_to_requested
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 63091e913ff..1ffd92b9bd9 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -111,14 +111,20 @@ describe Project do
expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git')
end
- it 'returns the full web URL for this repo' do
- project = Project.new(path: 'somewhere')
- expect(project.web_url).to eq("#{Gitlab.config.gitlab.url}/somewhere")
+ describe "#web_url" do
+ let(:project) { create(:empty_project, path: "somewhere") }
+
+ it 'returns the full web URL for this repo' do
+ expect(project.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.namespace.path}/somewhere")
+ end
end
- it 'returns the web URL without the protocol for this repo' do
- project = Project.new(path: 'somewhere')
- expect(project.web_url_without_protocol).to eq("#{Gitlab.config.gitlab.url.split('://')[1]}/somewhere")
+ describe "#web_url_without_protocol" do
+ let(:project) { create(:empty_project, path: "somewhere") }
+
+ it 'returns the web URL without the protocol for this repo' do
+ expect(project.web_url_without_protocol).to eq("#{Gitlab.config.gitlab.url.split('://')[1]}/#{project.namespace.path}/somewhere")
+ end
end
describe 'last_activity methods' do
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 439a492cea9..c04e842c67e 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -29,7 +29,7 @@ describe Projects::ForkService do
it "fails due to transaction failure" do
@to_project = fork_project(@from_project, @to_user, false)
expect(@to_project.errors).not_to be_empty
- expect(@to_project.errors[:base]).to include("Failed to fork repository")
+ expect(@to_project.errors[:base]).to include("Failed to fork repository via gitlab-shell")
end
end
diff --git a/spec/support/markdown_feature.rb b/spec/support/markdown_feature.rb
new file mode 100644
index 00000000000..2a868aed73b
--- /dev/null
+++ b/spec/support/markdown_feature.rb
@@ -0,0 +1,106 @@
+# This is a helper class used by the GitLab Markdown feature spec
+#
+# Because the feature spec only cares about the output of the Markdown, and the
+# test setup and teardown and parsing is fairly expensive, we only want to do it
+# once. Unfortunately RSpec will not let you access `let`s in a `before(:all)`
+# block, so we fake it by encapsulating all the shared setup in this class.
+#
+# The class renders `spec/fixtures/markdown.md.erb` using ERB, allowing for
+# reference to the factory-created objects.
+class MarkdownFeature
+ include FactoryGirl::Syntax::Methods
+
+ def user
+ @user ||= create(:user)
+ end
+
+ def group
+ unless @group
+ @group = create(:group)
+ @group.add_user(user, Gitlab::Access::DEVELOPER)
+ end
+
+ @group
+ end
+
+ # Direct references ----------------------------------------------------------
+
+ def project
+ @project ||= create(:project)
+ end
+
+ def issue
+ @issue ||= create(:issue, project: project)
+ end
+
+ def merge_request
+ @merge_request ||= create(:merge_request, :simple, source_project: project)
+ end
+
+ def snippet
+ @snippet ||= create(:project_snippet, project: project)
+ end
+
+ def commit
+ @commit ||= project.commit
+ end
+
+ def commit_range
+ unless @commit_range
+ commit2 = project.commit('HEAD~3')
+ @commit_range = CommitRange.new("#{commit.id}...#{commit2.id}", project)
+ end
+
+ @commit_range
+ end
+
+ def simple_label
+ @simple_label ||= create(:label, name: 'gfm', project: project)
+ end
+
+ def label
+ @label ||= create(:label, name: 'awaiting feedback', project: project)
+ end
+
+ # Cross-references -----------------------------------------------------------
+
+ def xproject
+ unless @xproject
+ namespace = create(:namespace, name: 'cross-reference')
+ @xproject = create(:project, namespace: namespace)
+ @xproject.team << [user, :developer]
+ end
+
+ @xproject
+ end
+
+ def xissue
+ @xissue ||= create(:issue, project: xproject)
+ end
+
+ def xmerge_request
+ @xmerge_request ||= create(:merge_request, :simple, source_project: xproject)
+ end
+
+ def xsnippet
+ @xsnippet ||= create(:project_snippet, project: xproject)
+ end
+
+ def xcommit
+ @xcommit ||= xproject.commit
+ end
+
+ def xcommit_range
+ unless @xcommit_range
+ xcommit2 = xproject.commit('HEAD~2')
+ @xcommit_range = CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject)
+ end
+
+ @xcommit_range
+ end
+
+ def raw_markdown
+ fixture = Rails.root.join('spec/fixtures/markdown.md.erb')
+ ERB.new(File.read(fixture)).result(binding)
+ end
+end
diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb
new file mode 100644
index 00000000000..9df226c3af8
--- /dev/null
+++ b/spec/support/matchers/markdown_matchers.rb
@@ -0,0 +1,156 @@
+# MarkdownMatchers
+#
+# Custom matchers for our custom HTML::Pipeline filters. These are used to test
+# that specific filters are or are not used by our defined pipelines.
+#
+# Must be included manually.
+module MarkdownMatchers
+ extend RSpec::Matchers::DSL
+ include Capybara::Node::Matchers
+
+ # RelativeLinkFilter
+ matcher :parse_relative_links do
+ set_default_markdown_messages
+
+ match do |actual|
+ link = actual.at_css('a:contains("Relative Link")')
+ image = actual.at_css('img[alt="Relative Image"]')
+
+ expect(link['href']).to end_with('master/doc/README.md')
+ expect(image['src']).to end_with('master/app/assets/images/touch-icon-ipad.png')
+ end
+ end
+
+ # EmojiFilter
+ matcher :parse_emoji do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('img.emoji', count: 10)
+ end
+ end
+
+ # TableOfContentsFilter
+ matcher :create_header_links do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('h1 a#gitlab-markdown')
+ expect(actual).to have_selector('h2 a#markdown')
+ expect(actual).to have_selector('h3 a#autolinkfilter')
+ end
+ end
+
+ # AutolinkFilter
+ matcher :create_autolinks do
+ def have_autolink(link)
+ have_link(link, href: link)
+ end
+
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_autolink('http://about.gitlab.com/')
+ expect(actual).to have_autolink('https://google.com/')
+ expect(actual).to have_autolink('ftp://ftp.us.debian.org/debian/')
+ expect(actual).to have_autolink('smb://foo/bar/baz')
+ expect(actual).to have_autolink('irc://irc.freenode.net/git')
+ expect(actual).to have_autolink('http://localhost:3000')
+
+ %w(code a kbd).each do |elem|
+ expect(body).not_to have_selector("#{elem} a")
+ end
+ end
+ end
+
+ # UserReferenceFilter
+ matcher :reference_users do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-project_member', count: 3)
+ end
+ end
+
+ # IssueReferenceFilter
+ matcher :reference_issues do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-issue', count: 3)
+ end
+ end
+
+ # MergeRequestReferenceFilter
+ matcher :reference_merge_requests do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-merge_request', count: 3)
+ expect(actual).to have_selector('em a.gfm-merge_request')
+ end
+ end
+
+ # SnippetReferenceFilter
+ matcher :reference_snippets do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-snippet', count: 2)
+ end
+ end
+
+ # CommitRangeReferenceFilter
+ matcher :reference_commit_ranges do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-commit_range', count: 2)
+ end
+ end
+
+ # CommitReferenceFilter
+ matcher :reference_commits do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-commit', count: 2)
+ end
+ end
+
+ # LabelReferenceFilter
+ matcher :reference_labels do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('a.gfm.gfm-label', count: 3)
+ end
+ end
+
+ # TaskListFilter
+ matcher :parse_task_lists do
+ set_default_markdown_messages
+
+ match do |actual|
+ expect(actual).to have_selector('ul.task-list', count: 2)
+ expect(actual).to have_selector('li.task-list-item', count: 7)
+ expect(actual).to have_selector('input[checked]', count: 3)
+ end
+ end
+end
+
+# Monkeypatch the matcher DSL so that we can reduce some noisy duplication for
+# setting the failure messages for these matchers
+module RSpec::Matchers::DSL::Macros
+ def set_default_markdown_messages
+ failure_message do
+ # expected to parse emoji, but didn't
+ "expected to #{description}, but didn't"
+ end
+
+ failure_message_when_negated do
+ # expected not to parse task lists, but did
+ "expected not to #{description}, but did"
+ end
+ end
+end