diff options
35 files changed, 147 insertions, 92 deletions
diff --git a/app/assets/stylesheets/highlight/white.scss b/app/assets/stylesheets/highlight/white.scss index 815cf367ae8..8d5822937a0 100644 --- a/app/assets/stylesheets/highlight/white.scss +++ b/app/assets/stylesheets/highlight/white.scss @@ -186,3 +186,11 @@ } } } + +.readme-holder .wiki, .note-body, .wiki-holder { + .white { + .highlight, pre, .hljs { + background: #F9F9F9; + } + } +} diff --git a/app/controllers/projects/base_tree_controller.rb b/app/controllers/projects/base_tree_controller.rb index 56c306063c8..a7b1b7b40e8 100644 --- a/app/controllers/projects/base_tree_controller.rb +++ b/app/controllers/projects/base_tree_controller.rb @@ -1,7 +1,6 @@ class Projects::BaseTreeController < Projects::ApplicationController include ExtractsPath - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project end diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index bad06e7aa2d..367d1295f34 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -3,7 +3,6 @@ class Projects::BlameController < Projects::ApplicationController include ExtractsPath # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 04aa044001e..2412800c493 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -3,7 +3,6 @@ class Projects::BlobController < Projects::ApplicationController include ExtractsPath # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project before_filter :authorize_push_code!, only: [:destroy] diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 9f50660a5ad..9ebd498e7fa 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -1,6 +1,5 @@ class Projects::BranchesController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :require_non_empty_project before_filter :authorize_download_code! diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index cf05e6ea220..dac858d8e16 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -3,7 +3,6 @@ # Not to be confused with CommitsController, plural. class Projects::CommitController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project before_filter :commit diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 53a0d063d8e..9476b6c0284 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -4,7 +4,6 @@ class Projects::CommitsController < Projects::ApplicationController include ExtractsPath # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 6d944025598..ffb8c2e4af1 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -1,6 +1,5 @@ class Projects::CompareController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 21d3970d65a..4a318cb7d56 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -1,6 +1,5 @@ class Projects::GraphsController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index 009089ee639..ada1aed0df7 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -3,7 +3,6 @@ class Projects::NetworkController < Projects::ApplicationController include ApplicationHelper # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index f4fdd616c50..fdbc4c5a098 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -3,7 +3,6 @@ class Projects::RawController < Projects::ApplicationController include ExtractsPath # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index 9ac189a78b3..5d9336bdc49 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -2,7 +2,6 @@ class Projects::RefsController < Projects::ApplicationController include ExtractsPath # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 6d8ef0f1ac8..bcd14a1c847 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -1,6 +1,5 @@ class Projects::RepositoriesController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :authorize_download_code! before_filter :require_non_empty_project diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 94794fb5dd0..162ddef0fec 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -1,8 +1,6 @@ class Projects::TagsController < Projects::ApplicationController # Authorize - before_filter :authorize_read_project! before_filter :require_non_empty_project - before_filter :authorize_download_code! before_filter :authorize_push_code!, only: [:create] before_filter :authorize_admin_project!, only: [:destroy] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 360894c7639..b5910c902e4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -4,7 +4,6 @@ class ProjectsController < ApplicationController before_filter :repository, except: [:new, :create] # Authorize - before_filter :authorize_read_project!, except: [:index, :new, :create] before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive, :retry_import] layout 'navless', only: [:new, :create, :fork] diff --git a/app/models/note.rb b/app/models/note.rb index f0ed7580b4c..4252d57ccb1 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -90,7 +90,7 @@ class Note < ActiveRecord::Base note_options.merge!(noteable: noteable) end - create(note_options) + create(note_options) unless cross_reference_disallowed?(noteable, mentioner) end def create_milestone_change_note(noteable, project, author, milestone) @@ -165,6 +165,15 @@ class Note < ActiveRecord::Base [:discussion, type.try(:underscore), id, line_code].join("-").to_sym end + # Determine if cross reference note should be created. + # eg. mentioning a commit in MR comments which exists inside a MR + # should not create "mentioned in" note. + def cross_reference_disallowed?(noteable, mentioner) + if mentioner.kind_of?(MergeRequest) + mentioner.commits.map(&:id).include? noteable.id + end + end + # Determine whether or not a cross-reference note already exists. def cross_reference_exists?(noteable, mentioner) gfm_reference = mentioner_gfm_ref(noteable, mentioner) diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb index 0020b4482e5..86705f5dabd 100644 --- a/app/models/project_services/flowdock_service.rb +++ b/app/models/project_services/flowdock_service.rb @@ -37,13 +37,12 @@ class FlowdockService < Service end def execute(push_data) - repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git") Flowdock::Git.post( push_data[:ref], push_data[:before], push_data[:after], token: token, - repo: repo_path, + repo: project.repository.path_to_repo, repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}", commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s", diff_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s", diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb index 6d2fc06a5d0..18fdd204ecd 100644 --- a/app/models/project_services/gemnasium_service.rb +++ b/app/models/project_services/gemnasium_service.rb @@ -38,14 +38,13 @@ class GemnasiumService < Service end def execute(push_data) - repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git") Gemnasium::GitlabService.execute( ref: push_data[:ref], before: push_data[:before], after: push_data[:after], token: token, api_key: api_key, - repo: repo_path + repo: project.repository.path_to_repo ) end end diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb index a897c4ab76b..fadebf968bc 100644 --- a/app/models/project_services/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -28,7 +28,7 @@ class GitlabCiService < CiService end def commit_status_path(sha) - project_url + "/builds/#{sha}/status.json?token=#{token}" + project_url + "/commits/#{sha}/status.json?token=#{token}" end def get_ci_build(sha) @@ -55,7 +55,7 @@ class GitlabCiService < CiService end def build_page(sha) - project_url + "/builds/#{sha}" + project_url + "/commits/#{sha}" end def builds_path diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index 814bf19970c..a25c5e207fb 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -59,7 +59,7 @@ - if note.attachment.image? = link_to note.attachment.secure_url, target: '_blank' do = image_tag note.attachment.secure_url, class: 'note-image-attach' - .attachment.pull-right + .attachment = link_to note.attachment.secure_url, target: "_blank" do %i.fa.fa-paperclip = note.attachment_identifier diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index ae4c0550a4f..a39e7ac028c 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,52 +1,48 @@ -require 'sidekiq/testing' - -Sidekiq::Testing.inline! do - Gitlab::Seeder.quiet do - project_urls = [ - 'https://github.com/documentcloud/underscore.git', - 'https://gitlab.com/gitlab-org/gitlab-ce.git', - 'https://gitlab.com/gitlab-org/gitlab-ci.git', - 'https://gitlab.com/gitlab-org/gitlab-shell.git', - 'https://gitlab.com/gitlab-org/gitlab-test.git', - 'https://github.com/twitter/flight.git', - 'https://github.com/twitter/typeahead.js.git', - 'https://github.com/h5bp/html5-boilerplate.git', - ] - - project_urls.each_with_index do |url, i| - group_path, project_path = url.split('/')[-2..-1] - - group = Group.find_by(path: group_path) - - unless group - group = Group.new( - name: group_path.titleize, - path: group_path - ) - group.description = Faker::Lorem.sentence - group.save - - group.add_owner(User.first) - end - - project_path.gsub!(".git", "") - - params = { - import_url: url, - namespace_id: group.id, - name: project_path.titleize, - description: Faker::Lorem.sentence, - visibility_level: Gitlab::VisibilityLevel.values.sample - } - - project = Projects::CreateService.new(User.first, params).execute - - if project.valid? - print '.' - else - puts project.errors.full_messages - print 'F' - end +Gitlab::Seeder.quiet do + project_urls = [ + 'https://github.com/documentcloud/underscore.git', + 'https://gitlab.com/gitlab-org/gitlab-ce.git', + 'https://gitlab.com/gitlab-org/gitlab-ci.git', + 'https://gitlab.com/gitlab-org/gitlab-shell.git', + 'https://gitlab.com/gitlab-org/gitlab-test.git', + 'https://github.com/twitter/flight.git', + 'https://github.com/twitter/typeahead.js.git', + 'https://github.com/h5bp/html5-boilerplate.git', + ] + + project_urls.each do |url| + group_path, project_path = url.split('/')[-2..-1] + + group = Group.find_by(path: group_path) + + unless group + group = Group.new( + name: group_path.titleize, + path: group_path + ) + group.description = Faker::Lorem.sentence + group.save + + group.add_owner(User.first) + end + + project_path.gsub!('.git', '') + + params = { + import_url: url, + namespace_id: group.id, + name: project_path.titleize, + description: Faker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample + } + + project = Projects::CreateService.new(User.first, params).execute + + if project.valid? + print '.' + else + puts project.errors.full_messages + print 'F' end end end diff --git a/db/fixtures/development/07_projects_visibility.rb b/db/fixtures/development/07_projects_visibility.rb new file mode 100644 index 00000000000..c3287584a07 --- /dev/null +++ b/db/fixtures/development/07_projects_visibility.rb @@ -0,0 +1,38 @@ +require Rails.root.join('db', 'fixtures', Rails.env, 'fixtures_development_helper') + +Gitlab::Seeder.quiet do + Gitlab::VisibilityLevel.options.each do |visibility_label, visibility_value| + visibility_label_downcase = visibility_label.downcase + begin + user = User.seed(:username) do |s| + username = "#{visibility_label_downcase}-owner" + s.username = username + s.name = "#{visibility_label} Owner" + s.email = "#{username}@example.com" + s.password = '12345678' + s.confirmed_at = DateTime.now + end[0] + + # import_url does not work for local paths, + # so we just copy the template repository in. + unless Project.find_with_namespace("#{user.namespace.id}/"\ + "#{visibility_label_downcase}") + params = { + name: "#{visibility_label} Project", + description: "#{visibility_label} Project description", + namespace_id: user.namespace.id, + visibility_level: visibility_value, + } + project = Projects::CreateService.new(user, params).execute + new_path = project.repository.path + FileUtils.rm_rf(new_path) + FileUtils.cp_r(FixturesDevelopmentHelper.template_project.repository.path, + new_path) + end + + print '.' + rescue ActiveRecord::RecordNotSaved + print 'F' + end + end +end diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/08_milestones.rb index 2296821e528..2296821e528 100644 --- a/db/fixtures/development/07_milestones.rb +++ b/db/fixtures/development/08_milestones.rb diff --git a/db/fixtures/development/fixtures_development_helper.rb b/db/fixtures/development/fixtures_development_helper.rb new file mode 100644 index 00000000000..22a7834bbee --- /dev/null +++ b/db/fixtures/development/fixtures_development_helper.rb @@ -0,0 +1,8 @@ +module FixturesDevelopmentHelper + class << self + def template_project + @template_project ||= Project. + find_with_namespace('gitlab-org/gitlab-test') + end + end +end diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index e0b13db020d..0755ac714e1 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -1,8 +1,10 @@ -password = if ENV['GITLAB_ROOT_PASSWORD'].blank? - "5iveL!fe" - else - ENV['GITLAB_ROOT_PASSWORD'] - end +if ENV['GITLAB_ROOT_PASSWORD'].blank? + password = '5iveL!fe' + expire_time = Time.now +else + password = ENV['GITLAB_ROOT_PASSWORD'] + expire_time = nil +end admin = User.create( email: "admin@example.com", @@ -10,7 +12,7 @@ admin = User.create( username: 'root', password: password, password_confirmation: password, - password_expires_at: Time.now, + password_expires_at: expire_time, theme_id: Gitlab::Theme::MARS ) diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 380beac708d..0bb02f1a357 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -91,7 +91,7 @@ module Backup protected def path_to_repo(project) - File.join(repos_path, project.path_with_namespace + '.git') + project.repository.path_to_repo end def path_to_bundle(project) diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb index 0fdd4dbe577..39d17def930 100644 --- a/lib/gitlab/git_ref_validator.rb +++ b/lib/gitlab/git_ref_validator.rb @@ -6,7 +6,7 @@ module Gitlab # Returns true for a valid reference name, false otherwise def validate(ref_name) Gitlab::Utils.system_silent( - %W(git check-ref-format refs/#{ref_name})) == 0 + %W(git check-ref-format refs/#{ref_name})) end end end diff --git a/lib/gitlab/seeder.rb b/lib/gitlab/seeder.rb index 31aa3528c4c..e816eedab9e 100644 --- a/lib/gitlab/seeder.rb +++ b/lib/gitlab/seeder.rb @@ -1,9 +1,13 @@ +require 'sidekiq/testing' + module Gitlab class Seeder def self.quiet mute_mailer SeedFu.quiet = true - yield + Sidekiq::Testing.inline! do + yield + end SeedFu.quiet = false puts "\nOK".green end diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index bc30364550a..bd184c27187 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -5,10 +5,9 @@ module Gitlab # Run system command without outputting to stdout. # # @param cmd [Array<String>] - # @return [Integer] exit status + # @return [Boolean] def system_silent(cmd) - IO.popen(cmd).close - $?.exitstatus + Popen::popen(cmd).last.zero? end end end diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab index 49a68c62293..6369c1e02ff 100644 --- a/lib/support/nginx/gitlab +++ b/lib/support/nginx/gitlab @@ -33,7 +33,8 @@ upstream gitlab { ## Normal HTTP host server { - listen *:80 default_server; + listen 0.0.0.0:80 default_server; + listen [::]:80 default_server; server_name YOUR_SERVER_FQDN; ## Replace this with something like gitlab.example.com server_tokens off; ## Don't show the nginx version number, a security best practice root /home/git/gitlab/public; diff --git a/lib/support/nginx/gitlab-ssl b/lib/support/nginx/gitlab-ssl index cbb198086b5..e992ebaf656 100644 --- a/lib/support/nginx/gitlab-ssl +++ b/lib/support/nginx/gitlab-ssl @@ -39,7 +39,8 @@ upstream gitlab { ## Normal HTTP host server { - listen *:80 default_server; + listen 0.0.0.0:80; + listen [::]:80 default_server; server_name YOUR_SERVER_FQDN; ## Replace this with something like gitlab.example.com server_tokens off; ## Don't show the nginx version number, a security best practice @@ -50,7 +51,8 @@ server { ## HTTPS host server { - listen 443 ssl; + listen 0.0.0.0:443 ssl; + listen [::]:443 ssl default_server; server_name YOUR_SERVER_FQDN; ## Replace this with something like gitlab.example.com server_tokens off; root /home/git/gitlab/public; diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 1e2d64b56c9..202e55c89ad 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -76,7 +76,7 @@ namespace :gitlab do desc "GITLAB | Build missing projects" task build_missing_projects: :environment do Project.find_each(batch_size: 1000) do |project| - path_to_repo = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git") + path_to_repo = project.repository.path_to_repo if File.exists?(path_to_repo) print '-' else diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb index ebc377047be..83277058fbb 100644 --- a/spec/models/gitlab_ci_service_spec.rb +++ b/spec/models/gitlab_ci_service_spec.rb @@ -34,11 +34,11 @@ describe GitlabCiService do end describe :commit_status_path do - it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/builds/2ab7834c/status.json?token=verySecret"} + it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret"} end describe :build_page do - it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/builds/2ab7834c"} + it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c"} end end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 2d839e9611b..6ab7162c15c 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -249,6 +249,12 @@ describe Note do its(:note) { should == "_mentioned in merge request !#{mergereq.iid}_" } end + context 'commit contained in a merge request' do + subject { Note.create_cross_reference_note(mergereq.commits.first, mergereq, author, project) } + + it { should be_nil } + end + context 'commit from issue' do subject { Note.create_cross_reference_note(commit, issue, author, project) } diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index dd7a0fc6cc8..beae71c02d9 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -37,8 +37,7 @@ describe API::API, api: true do context 'annotated tag' do it 'should create a new annotated tag' do # Identity must be set in .gitconfig to create annotated tag. - repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, - project.path_with_namespace + '.git') + repo_path = project.repository.path_to_repo system(*%W(git --git-dir=#{repo_path} config user.name #{user.name})) system(*%W(git --git-dir=#{repo_path} config user.email #{user.email})) |
