Commit 150fc0cc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' into mentioned_inside_mr

parents 6d775dda b33d4bc2
class Projects::BaseTreeController < Projects::ApplicationController class Projects::BaseTreeController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
end end
......
...@@ -3,7 +3,6 @@ class Projects::BlameController < Projects::ApplicationController ...@@ -3,7 +3,6 @@ class Projects::BlameController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
...@@ -3,7 +3,6 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -3,7 +3,6 @@ class Projects::BlobController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
before_filter :authorize_push_code!, only: [:destroy] before_filter :authorize_push_code!, only: [:destroy]
......
class Projects::BranchesController < Projects::ApplicationController class Projects::BranchesController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :require_non_empty_project before_filter :require_non_empty_project
before_filter :authorize_download_code! before_filter :authorize_download_code!
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# Not to be confused with CommitsController, plural. # Not to be confused with CommitsController, plural.
class Projects::CommitController < Projects::ApplicationController class Projects::CommitController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
before_filter :commit before_filter :commit
......
...@@ -4,7 +4,6 @@ class Projects::CommitsController < Projects::ApplicationController ...@@ -4,7 +4,6 @@ class Projects::CommitsController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
class Projects::CompareController < Projects::ApplicationController class Projects::CompareController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
class Projects::GraphsController < Projects::ApplicationController class Projects::GraphsController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
...@@ -3,7 +3,6 @@ class Projects::NetworkController < Projects::ApplicationController ...@@ -3,7 +3,6 @@ class Projects::NetworkController < Projects::ApplicationController
include ApplicationHelper include ApplicationHelper
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
...@@ -3,7 +3,6 @@ class Projects::RawController < Projects::ApplicationController ...@@ -3,7 +3,6 @@ class Projects::RawController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
...@@ -2,7 +2,6 @@ class Projects::RefsController < Projects::ApplicationController ...@@ -2,7 +2,6 @@ class Projects::RefsController < Projects::ApplicationController
include ExtractsPath include ExtractsPath
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
class Projects::RepositoriesController < Projects::ApplicationController class Projects::RepositoriesController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :require_non_empty_project before_filter :require_non_empty_project
......
class Projects::TagsController < Projects::ApplicationController class Projects::TagsController < Projects::ApplicationController
# Authorize # Authorize
before_filter :authorize_read_project!
before_filter :require_non_empty_project before_filter :require_non_empty_project
before_filter :authorize_download_code! before_filter :authorize_download_code!
before_filter :authorize_push_code!, only: [:create] before_filter :authorize_push_code!, only: [:create]
before_filter :authorize_admin_project!, only: [:destroy] before_filter :authorize_admin_project!, only: [:destroy]
......
...@@ -4,7 +4,6 @@ class ProjectsController < ApplicationController ...@@ -4,7 +4,6 @@ class ProjectsController < ApplicationController
before_filter :repository, except: [:new, :create] before_filter :repository, except: [:new, :create]
# Authorize # Authorize
before_filter :authorize_read_project!, except: [:index, :new, :create]
before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive, :retry_import] before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive, :retry_import]
layout 'navless', only: [:new, :create, :fork] layout 'navless', only: [:new, :create, :fork]
...@@ -52,8 +51,6 @@ class ProjectsController < ApplicationController ...@@ -52,8 +51,6 @@ class ProjectsController < ApplicationController
return return
end end
return authenticate_user! unless @project.public? || current_user
limit = (params[:limit] || 20).to_i limit = (params[:limit] || 20).to_i
@events = @project.events.recent @events = @project.events.recent
@events = event_filter.apply_filter(@events) @events = event_filter.apply_filter(@events)
......
...@@ -186,10 +186,6 @@ class Event < ActiveRecord::Base ...@@ -186,10 +186,6 @@ class Event < ActiveRecord::Base
data[:ref]["refs/heads"] data[:ref]["refs/heads"]
end end
def new_branch?
commit_from =~ /^00000/
end
def new_ref? def new_ref?
commit_from =~ /^00000/ commit_from =~ /^00000/
end end
......
...@@ -37,13 +37,12 @@ class FlowdockService < Service ...@@ -37,13 +37,12 @@ class FlowdockService < Service
end end
def execute(push_data) def execute(push_data)
repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
Flowdock::Git.post( Flowdock::Git.post(
push_data[:ref], push_data[:ref],
push_data[:before], push_data[:before],
push_data[:after], push_data[:after],
token: token, token: token,
repo: repo_path, repo: project.repository.path_to_repo,
repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}", repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}",
commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s", 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_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s",
......
...@@ -38,14 +38,13 @@ class GemnasiumService < Service ...@@ -38,14 +38,13 @@ class GemnasiumService < Service
end end
def execute(push_data) def execute(push_data)
repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git")
Gemnasium::GitlabService.execute( Gemnasium::GitlabService.execute(
ref: push_data[:ref], ref: push_data[:ref],
before: push_data[:before], before: push_data[:before],
after: push_data[:after], after: push_data[:after],
token: token, token: token,
api_key: api_key, api_key: api_key,
repo: repo_path repo: project.repository.path_to_repo
) )
end end
end end
...@@ -28,7 +28,7 @@ class GitlabCiService < CiService ...@@ -28,7 +28,7 @@ class GitlabCiService < CiService
end end
def commit_status_path(sha) def commit_status_path(sha)
project_url + "/builds/#{sha}/status.json?token=#{token}" project_url + "/commits/#{sha}/status.json?token=#{token}"
end end
def get_ci_build(sha) def get_ci_build(sha)
...@@ -55,7 +55,7 @@ class GitlabCiService < CiService ...@@ -55,7 +55,7 @@ class GitlabCiService < CiService
end end
def build_page(sha) def build_page(sha)
project_url + "/builds/#{sha}" project_url + "/commits/#{sha}"
end end
def builds_path def builds_path
......
...@@ -160,19 +160,19 @@ class GitPushService ...@@ -160,19 +160,19 @@ class GitPushService
ref_parts = ref.split('/') ref_parts = ref.split('/')
# Return if this is not a push to a branch (e.g. new commits) # Return if this is not a push to a branch (e.g. new commits)
ref_parts[1] =~ /heads/ && oldrev != "0000000000000000000000000000000000000000" ref_parts[1] =~ /heads/ && oldrev != Gitlab::Git::BLANK_SHA
end end
def push_to_new_branch?(ref, oldrev) def push_to_new_branch?(ref, oldrev)
ref_parts = ref.split('/') ref_parts = ref.split('/')
ref_parts[1] =~ /heads/ && oldrev == "0000000000000000000000000000000000000000" ref_parts[1] =~ /heads/ && oldrev == Gitlab::Git::BLANK_SHA
end end
def push_remove_branch?(ref, newrev) def push_remove_branch?(ref, newrev)
ref_parts = ref.split('/') ref_parts = ref.split('/')
ref_parts[1] =~ /heads/ && newrev == "0000000000000000000000000000000000000000" ref_parts[1] =~ /heads/ && newrev == Gitlab::Git::BLANK_SHA
end end
def push_to_branch?(ref) def push_to_branch?(ref)
......
...@@ -18,7 +18,7 @@ class SystemHooksService ...@@ -18,7 +18,7 @@ class SystemHooksService
def build_event_data(model, event) def build_event_data(model, event)
data = { data = {
event_name: build_event_name(model, event), event_name: build_event_name(model, event),
created_at: model.created_at created_at: model.created_at.xmlschema
} }
case model case model
......
...@@ -26,6 +26,10 @@ class AttachmentUploader < CarrierWave::Uploader::Base ...@@ -26,6 +26,10 @@ class AttachmentUploader < CarrierWave::Uploader::Base
Gitlab.config.gitlab.relative_url_root + "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" Gitlab.config.gitlab.relative_url_root + "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}"
end end
def url
Gitlab.config.gitlab.relative_url_root + super unless super.nil?
end
def file_storage? def file_storage?
self.class.storage == CarrierWave::Storage::File self.class.storage == CarrierWave::Storage::File
end end
......
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
title: title:
%code= @key.title %code= @key.title
%p %p
If this key was added in error, you can remove it here: If this key was added in error, you can remove it under
= link_to "SSH Keys", profile_keys_url = link_to "SSH Keys", profile_keys_url
...@@ -2,6 +2,6 @@ Hi <%= @user.name %>! ...@@ -2,6 +2,6 @@ Hi <%= @user.name %>!
A new public key was added to your account: A new public key was added to your account:
title.................. <%= @key.title %> Title: <%= @key.title %>
If this key was added in error, you can remove it here: <%= profile_keys_url %> If this key was added in error, you can remove it at <%= profile_keys_url %>
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
tree_join(@commit.sha, @path)), class: 'btn btn-small' tree_join(@commit.sha, @path)), class: 'btn btn-small'
- if allowed_tree_edit? - if allowed_tree_edit?
= link_to '#modal-remove-blob', class: "remove-blob btn btn-small btn-remove", "data-toggle" => "modal" do = button_tag class: 'remove-blob btn btn-small btn-remove',
'data-toggle' => 'modal', 'data-target' => '#modal-remove-blob' do
Remove Remove
...@@ -199,7 +199,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da ...@@ -199,7 +199,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da
# Make sure GitLab can write to the log/ and tmp/ directories # Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/ sudo chown -R git log/
sudo chown -R git tmp/ sudo chown -R git tmp/
sudo chmod -R u+rwX log/ sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/ sudo chmod -R u+rwX tmp/
# Create directory for satellites # Create directory for satellites
......
...@@ -29,7 +29,7 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps ...@@ -29,7 +29,7 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps
step 'this project has push event' do step 'this project has push event' do
data = { data = {
before: "0000000000000000000000000000000000000000", before: Gitlab::Git::BLANK_SHA,
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
ref: "refs/heads/new_design", ref: "refs/heads/new_design",
user_id: @user.id, user_id: @user.id,
......
...@@ -78,7 +78,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps ...@@ -78,7 +78,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
end end
step 'I click on "Remove"' do step 'I click on "Remove"' do
click_link 'Remove' click_button 'Remove'
end end
step 'I click on "Remove file"' do step 'I click on "Remove file"' do
......
...@@ -32,7 +32,7 @@ module SharedProject ...@@ -32,7 +32,7 @@ module SharedProject
@project = Project.find_by(name: "Shop") @project = Project.find_by(name: "Shop")
data = { data = {
before: "0000000000000000000000000000000000000000", before: Gitlab::Git::BLANK_SHA,
after: "6d394385cf567f80a8fd85055db1ab4c5295806f", after: "6d394385cf567f80a8fd85055db1ab4c5295806f",
ref: "refs/heads/fix", ref: "refs/heads/fix",
user_id: @user.id, user_id: @user.id,
......
...@@ -91,7 +91,7 @@ module Backup ...@@ -91,7 +91,7 @@ module Backup
protected protected
def path_to_repo(project) def path_to_repo(project)
File.join(repos_path, project.path_with_namespace + '.git') project.repository.path_to_repo
end end
def path_to_bundle(project) def path_to_bundle(project)
......
...@@ -76,7 +76,7 @@ namespace :gitlab do ...@@ -76,7 +76,7 @@ namespace :gitlab do
desc "GITLAB | Build missing projects" desc "GITLAB | Build missing projects"
task build_missing_projects: :environment do task build_missing_projects: :environment do
Project.find_each(batch_size: 1000) do |project| 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) if File.exists?(path_to_repo)
print '-' print '-'
else else
......
...@@ -36,7 +36,7 @@ describe Event do ...@@ -36,7 +36,7 @@ describe Event do
@user = project.owner @user = project.owner
data = { data = {
before: "0000000000000000000000000000000000000000", before: Gitlab::Git::BLANK_SHA,
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
ref: "refs/heads/master", ref: "refs/heads/master",
user_id: @user.id, user_id: @user.id,
...@@ -60,7 +60,6 @@ describe Event do ...@@ -60,7 +60,6 @@ describe Event do
it { @event.push?.should be_true } it { @event.push?.should be_true }
it { @event.proper?.should be_true } it { @event.proper?.should be_true }
it { @event.new_branch?.should be_true }
it { @event.tag?.should be_false } it { @event.tag?.should be_false }
it { @event.branch_name.should == "master" } it { @event.branch_name.should == "master" }
it { @event.author.should == @user } it { @event.author.should == @user }
......
...@@ -34,11 +34,11 @@ describe GitlabCiService do ...@@ -34,11 +34,11 @@ describe GitlabCiService do
end end
describe :commit_status_path do 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 end
describe :build_page do 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 end
end end
...@@ -37,8 +37,7 @@ describe API::API, api: true do ...@@ -37,8 +37,7 @@ describe API::API, api: true do
context 'annotated tag' do context 'annotated tag' do
it 'should create a new annotated tag' do it 'should create a new annotated tag' do
# Identity must be set in .gitconfig to create annotated tag. # Identity must be set in .gitconfig to create annotated tag.
repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, repo_path = project.repository.path_to_repo
project.path_with_namespace + '.git')
system(*%W(git --git-dir=#{repo_path} config user.name #{user.name})) system(*%W(git --git-dir=#{repo_path} config user.name #{user.name}))
system(*%W(git --git-dir=#{repo_path} config user.email #{user.email})) system(*%W(git --git-dir=#{repo_path} config user.email #{user.email}))
......
...@@ -8,7 +8,7 @@ describe GitPushService do ...@@ -8,7 +8,7 @@ describe GitPushService do
let (:service) { GitPushService.new } let (:service) { GitPushService.new }
before do before do
@blankrev = '0000000000000000000000000000000000000000' @blankrev = Gitlab::Git::BLANK_SHA
@oldrev = sample_commit.parent_id @oldrev = sample_commit.parent_id
@newrev = sample_commit.id @newrev = sample_commit.id
@ref = 'refs/heads/master' @ref = 'refs/heads/master'
......
...@@ -3,6 +3,16 @@ require 'rspec/mocks' ...@@ -3,6 +3,16 @@ require 'rspec/mocks'
module TestEnv module TestEnv
extend self extend self
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA = {
'feature' => '0b4bc9a',
'feature_conflict' => 'bb5206f',
'fix' => '12d65c8',
'improve/awesome' => '5937ac0',
'markdown' => '0ed8c6c',
'master' => '5937ac0'
}
# Test environment # Test environment
# #
# See gitlab.yml.example test section for paths # See gitlab.yml.example test section for paths
...@@ -18,13 +28,13 @@ module TestEnv ...@@ -18,13 +28,13 @@ module TestEnv
if File.directory?(tmp_test_path) if File.directory?(tmp_test_path)
Dir.entries(tmp_test_path).each do |entry| Dir.entries(tmp_test_path).each do |entry|
unless ['.', '..', 'gitlab-shell'].include?(entry) unless ['.', '..', 'gitlab-shell', factory_repo_name].include?(entry)
FileUtils.rm_r(File.join(tmp_test_path, entry)) FileUtils.rm_r(File.join(tmp_test_path, entry))
end end
end end
end end
FileUtils.mkdir_p(tmp_test_path) FileUtils.mkdir_p(repos_path)
# Setup GitLab shell for test instance # Setup GitLab shell for test instance
setup_gitlab_shell setup_gitlab_shell
...@@ -49,13 +59,32 @@ module TestEnv ...@@ -49,13 +59,32 @@ module TestEnv
clone_url = "https://gitlab.com/gitlab-org/#{factory_repo_name}.git" clone_url = "https://gitlab.com/gitlab-org/#{factory_repo_name}.git"
unless File.directory?(factory_repo_path) unless File.directory?(factory_repo_path)
git_cmd = %W(git clone --bare #{clone_url} #{factory_repo_path}) system(*%W(git clone #{clone_url} #{factory_repo_path}))
system(*git_cmd) end
Dir.chdir(factory_repo_path) do
BRANCH_SHA.each do |branch, sha|
# Try to reset without fetching to avoid using the network.
reset = %W(git update-ref refs/heads/#{branch} #{sha})
unless system(*reset)
if system(*%w(git fetch origin))
unless system(*reset)
raise 'The fetched test seed '\
'does not contain the required revision.'
end
else
raise 'Could not fetch test seed repository.'
end
end
end
end end
# We must copy bare repositories because we will push to them.
system(*%W(git clone --bare #{factory_repo_path} #{factory_repo_path_bare}))
end end
def copy_repo(project) def copy_repo(project)
base_repo_path = File.expand_path(factory_repo_path) base_repo_path = File.expand_path(factory_repo_path_bare)
target_repo_path = File.expand_path(repos_path + "/#{project.namespace.path}/#{project.path}.git") target_repo_path = File.expand_path(repos_path + "/#{project.namespace.path}/#{project.path}.git")
FileUtils.mkdir_p(target_repo_path) FileUtils.mkdir_p(target_repo_path)
FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) FileUtils.cp_r("#{base_repo_path}/.", target_repo_path)
...@@ -69,7 +98,11 @@ module TestEnv ...@@ -69,7 +98,11 @@ module TestEnv
private private
def factory_repo_path def factory_repo_path
@factory_repo_path ||= repos_path + "/root/#{factory_repo_name}.git" @factory_repo_path ||= Rails.root.join('tmp', 'tests', factory_repo_name)
end
def factory_repo_path_bare
factory_repo_path.to_s + '_bare'
end end
def factory_repo_name def factory_repo_name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment