Commit d76db397 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-06-11

# Conflicts:
#	spec/models/project_spec.rb

[ci skip]
parents 22dcb132 75797ac3
...@@ -31,10 +31,15 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => { ...@@ -31,10 +31,15 @@ export const openMergeRequest = ({ commit, dispatch }, { projectPath, id }) => {
commit(rootTypes.CLEAR_PROJECTS, null, { root: true }); commit(rootTypes.CLEAR_PROJECTS, null, { root: true });
commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true }); commit(rootTypes.SET_CURRENT_MERGE_REQUEST, `${id}`, { root: true });
commit(rootTypes.RESET_OPEN_FILES, null, { root: true }); commit(rootTypes.RESET_OPEN_FILES, null, { root: true });
dispatch('pipelines/stopPipelinePolling', null, { root: true });
dispatch('pipelines/clearEtagPoll', null, { root: true });
dispatch('pipelines/resetLatestPipeline', null, { root: true }); dispatch('pipelines/resetLatestPipeline', null, { root: true });
dispatch('setCurrentBranchId', '', { root: true }); dispatch('setCurrentBranchId', '', { root: true });
dispatch('pipelines/stopPipelinePolling', null, { root: true })
.then(() => {
dispatch('pipelines/clearEtagPoll', null, { root: true });
})
.catch(e => {
throw e;
});
router.push(`/project/${projectPath}/merge_requests/${id}`); router.push(`/project/${projectPath}/merge_requests/${id}`);
}; };
......
...@@ -12,8 +12,12 @@ let eTagPoll; ...@@ -12,8 +12,12 @@ let eTagPoll;
export const clearEtagPoll = () => { export const clearEtagPoll = () => {
eTagPoll = null; eTagPoll = null;
}; };
export const stopPipelinePolling = () => eTagPoll && eTagPoll.stop(); export const stopPipelinePolling = () => {
export const restartPipelinePolling = () => eTagPoll && eTagPoll.restart(); if (eTagPoll) eTagPoll.stop();
};
export const restartPipelinePolling = () => {
if (eTagPoll) eTagPoll.restart();
};
export const requestLatestPipeline = ({ commit }) => commit(types.REQUEST_LATEST_PIPELINE); export const requestLatestPipeline = ({ commit }) => commit(types.REQUEST_LATEST_PIPELINE);
export const receiveLatestPipelineError = ({ commit, dispatch }) => { export const receiveLatestPipelineError = ({ commit, dispatch }) => {
...@@ -51,9 +55,9 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => { ...@@ -51,9 +55,9 @@ export const fetchLatestPipeline = ({ dispatch, rootGetters }) => {
Visibility.change(() => { Visibility.change(() => {
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
eTagPoll.restart(); dispatch('restartPipelinePolling');
} else { } else {
eTagPoll.stop(); dispatch('stopPipelinePolling');
} }
}); });
}; };
......
<script> <script>
import tooltip from '~/vue_shared/directives/tooltip';
import MrWidgetAuthor from './mr_widget_author.vue'; import MrWidgetAuthor from './mr_widget_author.vue';
export default { export default {
name: 'MRWidgetAuthorTime', name: 'MrWidgetAuthorTime',
components: { components: {
MrWidgetAuthor, MrWidgetAuthor,
}, },
directives: {
tooltip,
},
props: { props: {
actionText: { actionText: {
type: String, type: String,
...@@ -32,8 +36,7 @@ ...@@ -32,8 +36,7 @@
<mr-widget-author :author="author" /> <mr-widget-author :author="author" />
<time <time
:title="dateTitle" :title="dateTitle"
data-toggle="tooltip" v-tooltip
data-placement="top"
data-container="body" data-container="body"
> >
{{ dateReadable }} {{ dateReadable }}
......
<script> <script>
import mrWidgetAuthorTime from '../../components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '../../components/mr_widget_author_time.vue';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
export default { export default {
name: 'MRWidgetClosed', name: 'MRWidgetClosed',
components: { components: {
mrWidgetAuthorTime, MrWidgetAuthorTime,
statusIcon, statusIcon,
}, },
props: { props: {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import loadingIcon from '~/vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import mrWidgetAuthorTime from '../../components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '../../components/mr_widget_author_time.vue';
import statusIcon from '../mr_widget_status_icon.vue'; import statusIcon from '../mr_widget_status_icon.vue';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
tooltip, tooltip,
}, },
components: { components: {
mrWidgetAuthorTime, MrWidgetAuthorTime,
loadingIcon, loadingIcon,
statusIcon, statusIcon,
ClipboardButton, ClipboardButton,
......
...@@ -58,8 +58,13 @@ table { ...@@ -58,8 +58,13 @@ table {
display: none; display: none;
} }
table,
tbody,
td { td {
display: block; display: block;
}
td {
color: $gl-text-color-secondary; color: $gl-text-color-secondary;
} }
......
...@@ -8,6 +8,7 @@ module Ci ...@@ -8,6 +8,7 @@ module Ci
include Gitlab::OptimisticLocking include Gitlab::OptimisticLocking
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
include AtomicInternalId include AtomicInternalId
include EnumWithNil
prepend ::EE::Ci::Pipeline prepend ::EE::Ci::Pipeline
...@@ -65,7 +66,7 @@ module Ci ...@@ -65,7 +66,7 @@ module Ci
after_create :keep_around_commits, unless: :importing? after_create :keep_around_commits, unless: :importing?
enum source: { enum_with_nil source: {
unknown: nil, unknown: nil,
push: 1, push: 1,
web: 2, web: 2,
...@@ -77,7 +78,7 @@ module Ci ...@@ -77,7 +78,7 @@ module Ci
chat: 8 chat: 8
} }
enum config_source: { enum_with_nil config_source: {
unknown_source: nil, unknown_source: nil,
repository_source: 1, repository_source: 1,
auto_devops_source: 2 auto_devops_source: 2
...@@ -616,17 +617,6 @@ module Ci ...@@ -616,17 +617,6 @@ module Ci
@latest_builds_with_artifacts ||= builds.latest.with_artifacts_archive.to_a @latest_builds_with_artifacts ||= builds.latest.with_artifacts_archive.to_a
end end
# Rails 5.0 autogenerated question mark enum methods return wrong result if enum value is nil.
# They always return `false`.
# These methods overwrite autogenerated ones to return correct results.
def unknown?
Gitlab.rails5? ? source.nil? : super
end
def unknown_source?
Gitlab.rails5? ? config_source.nil? : super
end
private private
def ci_yaml_from_repo def ci_yaml_from_repo
......
...@@ -3,6 +3,7 @@ class CommitStatus < ActiveRecord::Base ...@@ -3,6 +3,7 @@ class CommitStatus < ActiveRecord::Base
include Importable include Importable
include AfterCommitQueue include AfterCommitQueue
include Presentable include Presentable
include EnumWithNil
self.table_name = 'ci_builds' self.table_name = 'ci_builds'
...@@ -39,7 +40,7 @@ class CommitStatus < ActiveRecord::Base ...@@ -39,7 +40,7 @@ class CommitStatus < ActiveRecord::Base
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
scope :after_stage, -> (index) { where('stage_idx > ?', index) } scope :after_stage, -> (index) { where('stage_idx > ?', index) }
enum failure_reason: { enum_with_nil failure_reason: {
unknown_failure: nil, unknown_failure: nil,
script_failure: 1, script_failure: 1,
api_failure: 2, api_failure: 2,
...@@ -190,11 +191,4 @@ class CommitStatus < ActiveRecord::Base ...@@ -190,11 +191,4 @@ class CommitStatus < ActiveRecord::Base
v =~ /\d+/ ? v.to_i : v v =~ /\d+/ ? v.to_i : v
end end
end end
# Rails 5.0 autogenerated question mark enum methods return wrong result if enum value is nil.
# They always return `false`.
# This method overwrites the autogenerated one to return correct result.
def unknown_failure?
Gitlab.rails5? ? failure_reason.nil? : super
end
end end
module EnumWithNil
extend ActiveSupport::Concern
included do
def self.enum_with_nil(definitions)
# use original `enum` to auto-define all methods
enum(definitions)
# override auto-defined methods only for the
# key which uses nil value
definitions.each do |name, values|
next unless key_with_nil = values.key(nil)
# E.g. for enum_with_nil failure_reason: { unknown_failure: nil }
# this overrides auto-generated method `unknown_failure?`
define_method("#{key_with_nil}?") do
Gitlab.rails5? ? self[name].nil? : super()
end
# E.g. for enum_with_nil failure_reason: { unknown_failure: nil }
# this overrides auto-generated method `failure_reason`
define_method(name) do
orig = super()
return orig unless Gitlab.rails5?
return orig unless orig.nil?
self.class.public_send(name.to_s.pluralize).key(nil) # rubocop:disable GitlabSecurity/PublicSend
end
end
end
end
end
...@@ -19,7 +19,7 @@ module Commits ...@@ -19,7 +19,7 @@ module Commits
new_commit = create_commit! new_commit = create_commit!
success(result: new_commit) success(result: new_commit)
rescue ValidationError, ChangeError, Gitlab::Git::Index::IndexError, Gitlab::Git::CommitError, Gitlab::Git::HooksService::PreReceiveError => ex rescue ValidationError, ChangeError, Gitlab::Git::Index::IndexError, Gitlab::Git::CommitError, Gitlab::Git::PreReceiveError => ex
error(ex.message) error(ex.message)
end end
......
...@@ -14,7 +14,7 @@ class CreateBranchService < BaseService ...@@ -14,7 +14,7 @@ class CreateBranchService < BaseService
else else
error('Invalid reference name') error('Invalid reference name')
end end
rescue Gitlab::Git::HooksService::PreReceiveError => ex rescue Gitlab::Git::PreReceiveError => ex
error(ex.message) error(ex.message)
end end
......
...@@ -16,7 +16,7 @@ class DeleteBranchService < BaseService ...@@ -16,7 +16,7 @@ class DeleteBranchService < BaseService
else else
error('Failed to remove branch') error('Failed to remove branch')
end end
rescue Gitlab::Git::HooksService::PreReceiveError => ex rescue Gitlab::Git::PreReceiveError => ex
error(ex.message) error(ex.message)
end end
......
...@@ -13,7 +13,7 @@ module MergeRequests ...@@ -13,7 +13,7 @@ module MergeRequests
source, source,
merge_request.target_branch, merge_request.target_branch,
merge_request: merge_request) merge_request: merge_request)
rescue Gitlab::Git::HooksService::PreReceiveError => e rescue Gitlab::Git::PreReceiveError => e
raise MergeError, e.message raise MergeError, e.message
rescue StandardError => e rescue StandardError => e
raise MergeError, "Something went wrong during merge: #{e.message}" raise MergeError, "Something went wrong during merge: #{e.message}"
......
...@@ -81,7 +81,7 @@ module MergeRequests ...@@ -81,7 +81,7 @@ module MergeRequests
message = params[:commit_message] || merge_request.merge_commit_message message = params[:commit_message] || merge_request.merge_commit_message
repository.merge(current_user, source, merge_request, message) repository.merge(current_user, source, merge_request, message)
rescue Gitlab::Git::HooksService::PreReceiveError => e rescue Gitlab::Git::PreReceiveError => e
handle_merge_error(log_message: e.message) handle_merge_error(log_message: e.message)
raise MergeError, 'Something went wrong during merge pre-receive hook' raise MergeError, 'Something went wrong during merge pre-receive hook'
rescue => e rescue => e
......
...@@ -13,7 +13,7 @@ module Tags ...@@ -13,7 +13,7 @@ module Tags
new_tag = repository.add_tag(current_user, tag_name, target, message) new_tag = repository.add_tag(current_user, tag_name, target, message)
rescue Gitlab::Git::Repository::TagExistsError rescue Gitlab::Git::Repository::TagExistsError
return error("Tag #{tag_name} already exists") return error("Tag #{tag_name} already exists")
rescue Gitlab::Git::HooksService::PreReceiveError => ex rescue Gitlab::Git::PreReceiveError => ex
return error(ex.message) return error(ex.message)
end end
......
...@@ -21,7 +21,7 @@ module Tags ...@@ -21,7 +21,7 @@ module Tags
else else
error('Failed to remove tag') error('Failed to remove tag')
end end
rescue Gitlab::Git::HooksService::PreReceiveError => ex rescue Gitlab::Git::PreReceiveError => ex
error(ex.message) error(ex.message)
end end
......
...@@ -13,7 +13,7 @@ class ValidateNewBranchService < BaseService ...@@ -13,7 +13,7 @@ class ValidateNewBranchService < BaseService
end end
success success
rescue Gitlab::Git::HooksService::PreReceiveError => ex rescue Gitlab::Git::PreReceiveError => ex
error(ex.message) error(ex.message)
end end
end end
---
title: Fix overflowing Failed Jobs table in sm viewports on IE11
merge_request:
author:
type: fixed
---
title: Move some Gitaly RPC's to opt-out
merge_request: 19591
author:
type: other
---
title: Use Tooltip component in MrWidgetAuthorTime vue comonent
merge_request: 19635
author: George Tsiolis
type: performance
...@@ -41,7 +41,12 @@ module ActiveRecord ...@@ -41,7 +41,12 @@ module ActiveRecord
# Abstract representation of an index definition on a table. Instances of # Abstract representation of an index definition on a table. Instances of
# this type are typically created and returned by methods in database # this type are typically created and returned by methods in database
# adapters. e.g. ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#indexes # adapters. e.g. ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#indexes
class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :orders, :where, :type, :using, :opclasses) #:nodoc: attrs = [:table, :name, :unique, :columns, :lengths, :orders, :where, :type, :using, :opclasses]
# In Rails 5 the second last attribute is newly `:comment`
attrs.insert(-2, :comment) if Gitlab.rails5?
class IndexDefinition < Struct.new(*attrs) #:nodoc:
end end
end end
end end
......
...@@ -301,9 +301,9 @@ sudo usermod -aG redis git ...@@ -301,9 +301,9 @@ sudo usermod -aG redis git
### Clone the Source ### Clone the Source
# Clone GitLab repository # Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 10-8-stable gitlab sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 11-0-stable gitlab
**Note:** You can change `10-8-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server! **Note:** You can change `11-0-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server!
### Configure It ### Configure It
......
This diff is collapsed.
...@@ -7,10 +7,8 @@ module Gitlab ...@@ -7,10 +7,8 @@ module Gitlab
end end
def value def value
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
@value ||= count_commits @value ||= count_commits
end end
end
private private
...@@ -21,19 +19,11 @@ module Gitlab ...@@ -21,19 +19,11 @@ module Gitlab
def count_commits def count_commits
return unless ref return unless ref
repository = @project.repository.raw_repository gitaly_commit_client.commit_count(ref, after: @from)
sha = @project.repository.commit(ref).sha end
cmd = %W(git --git-dir=#{repository.path} log)
cmd << '--format=%H'
cmd << "--after=#{@from.iso8601}"
cmd << sha
output, status = Gitlab::Popen.popen(cmd)
raise IOError, output unless status.zero?
output.lines.count def gitaly_commit_client
Gitlab::GitalyClient::CommitService.new(@project.repository.raw_repository)
end end
def ref def ref
......
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
private private
def load_blame def load_blame
raw_output = @repo.gitaly_migrate(:blame) do |is_enabled| raw_output = @repo.gitaly_migrate(:blame, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled if is_enabled
load_blame_by_gitaly load_blame_by_gitaly
else else
......
...@@ -20,7 +20,7 @@ module Gitlab ...@@ -20,7 +20,7 @@ module Gitlab
end end
result[:newrev] result[:newrev]
rescue Gitlab::Git::HooksService::PreReceiveError => e rescue Gitlab::Git::PreReceiveError => e
message = "Custom Hook failed: #{e.message}" message = "Custom Hook failed: #{e.message}"
raise Gitlab::Git::Wiki::OperationError, message raise Gitlab::Git::Wiki::OperationError, message
end end
......
...@@ -11,7 +11,7 @@ module Gitlab ...@@ -11,7 +11,7 @@ module Gitlab
def initialize(name, repository) def initialize(name, repository)
@name = name @name = name
@repository = repository @repository = repository
@path = File.join(repo_path.strip, 'hooks', name) @path = File.join(repo_path, 'hooks', name)
end end
def repo_path def repo_path
...@@ -95,13 +95,13 @@ module Gitlab ...@@ -95,13 +95,13 @@ module Gitlab
args = [ref, oldrev, newrev] args = [ref, oldrev, newrev]
stdout, stderr, status = Open3.capture3(env, path, *args, options) stdout, stderr, status = Open3.capture3(env, path, *args, options)
[status.success?, Gitlab::Utils.nlbr(stderr.presence || stdout)] [status.success?, stderr.presence || stdout]
end end
def retrieve_error_message(stderr, stdout) def retrieve_error_message(stderr, stdout)
err_message = stderr.read err_message = stderr.read
err_message = err_message.blank? ? stdout.read : err_message err_message = err_message.blank? ? stdout.read : err_message
Gitlab::Utils.nlbr(err_message) err_message
end end
end end
end end
......
module Gitlab module Gitlab
module Git module Git
class HooksService class HooksService
PreReceiveError = Class.new(StandardError)
attr_accessor :oldrev, :newrev, :ref attr_accessor :oldrev, :newrev, :ref
def execute(pusher, repository, oldrev, newrev, ref) def execute(pusher, repository, oldrev, newrev, ref)
......
module Gitlab
module Git
#
# PreReceiveError is special because its message gets displayed to users
# in the web UI. To prevent XSS we sanitize the message on
# initialization.
class PreReceiveError < StandardError
def initialize(msg = '')
super(nlbr(msg))
end
private
# In gitaly-ruby we override this method to do nothing, so that
# sanitization happens in gitlab-rails only.
def nlbr(str)
Gitlab::Utils.nlbr(str)
end
end
end
end
...@@ -533,7 +533,7 @@ module Gitlab ...@@ -533,7 +533,7 @@ module Gitlab
def count_commits(options) def count_commits(options)
count_commits_options = process_count_commits_options(options) count_commits_options = process_count_commits_options(options)
gitaly_migrate(:count_commits) do |is_enabled| gitaly_migrate(:count_commits, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled if is_enabled
count_commits_by_gitaly(count_commits_options) count_commits_by_gitaly(count_commits_options)
else else
...@@ -738,7 +738,7 @@ module Gitlab ...@@ -738,7 +738,7 @@ module Gitlab
# #
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/330 # Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/330
def commit_count(ref) def commit_count(ref)
gitaly_migrate(:commit_count) do |is_enabled| gitaly_migrate(:commit_count, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled if is_enabled
gitaly_commit_client.commit_count(ref) gitaly_commit_client.commit_count(ref)
else else
......
...@@ -20,7 +20,7 @@ module Gitlab ...@@ -20,7 +20,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_tag, request) response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_tag, request)
if pre_receive_error = response.pre_receive_error.presence if pre_receive_error = response.pre_receive_error.presence
raise Gitlab::Git::HooksService::PreReceiveError, pre_receive_error raise Gitlab::Git::PreReceiveError, pre_receive_error
end end
end end
...@@ -35,7 +35,7 @@ module Gitlab ...@@ -35,7 +35,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :operation_service, :user_create_tag, request) response = GitalyClient.call(@repository.storage, :operation_service, :user_create_tag, request)
if pre_receive_error = response.pre_receive_error.presence if pre_receive_error = response.pre_receive_error.presence
raise Gitlab::Git::HooksService::PreReceiveError, pre_receive_error raise Gitlab::Git::PreReceiveError, pre_receive_error
elsif response.exists elsif response.exists
raise Gitlab::Git::Repository::TagExistsError raise Gitlab::Git::Repository::TagExistsError
end end
...@@ -56,7 +56,7 @@ module Gitlab ...@@ -56,7 +56,7 @@ module Gitlab
:user_create_branch, request) :user_create_branch, request)
if response.pre_receive_error.present? if response.pre_receive_error.present?
raise Gitlab::Git::HooksService::PreReceiveError.new(response.pre_receive_error) raise Gitlab::Git::PreReceiveError.new(response.pre_receive_error)
end end
branch = response.branch branch = response.branch
...@@ -76,7 +76,7 @@ module Gitlab ...@@ -76,7 +76,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_branch, request) response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_branch, request)
if pre_receive_error = response.pre_receive_error.presence if pre_receive_error = response.pre_receive_error.presence
raise Gitlab::Git::HooksService::PreReceiveError, pre_receive_error raise Gitlab::Git::PreReceiveError, pre_receive_error
end end
end end
...@@ -106,7 +106,7 @@ module Gitlab ...@@ -106,7 +106,7 @@ module Gitlab
second_response = response_enum.next second_response = response_enum.next
if second_response.pre_receive_error.present? if second_response.pre_receive_error.present?
raise Gitlab::Git::HooksService::PreReceiveError, second_response.pre_receive_error raise Gitlab::Git::PreReceiveError, second_response.pre_receive_error
end end
branch_update = second_response.branch_update branch_update = second_response.branch_update
...@@ -175,7 +175,7 @@ module Gitlab ...@@ -175,7 +175,7 @@ module Gitlab
) )
if response.pre_receive_error.presence if response.pre_receive_error.presence
raise Gitlab::Git::HooksService::PreReceiveError, response.pre_receive_error raise Gitlab::Git::PreReceiveError, response.pre_receive_error
elsif response.git_error.presence elsif response.git_error.presence
raise Gitlab::Git::Repository::GitError, response.git_error raise Gitlab::Git::Repository::GitError, response.git_error
else else
...@@ -242,7 +242,7 @@ module Gitlab ...@@ -242,7 +242,7 @@ module Gitlab
:user_commit_files, req_enum, remote_storage: start_repository.storage) :user_commit_files, req_enum, remote_storage: start_repository.storage)
if (pre_receive_error = response.pre_receive_error.presence) if (pre_receive_error = response.pre_receive_error.presence)
raise Gitlab::Git::HooksService::PreReceiveError, pre_receive_error raise Gitlab::Git::PreReceiveError, pre_receive_error
end end
if (index_error = response.index_error.presence) if (index_error = response.index_error.presence)
...@@ -280,7 +280,7 @@ module Gitlab ...@@ -280,7 +280,7 @@ module Gitlab
def handle_cherry_pick_or_revert_response(response) def handle_cherry_pick_or_revert_response(response)
if response.pre_receive_error.presence if response.pre_receive_error.presence
raise Gitlab::Git::HooksService::PreReceiveError, response.pre_receive_error raise Gitlab::Git::PreReceiveError, response.pre_receive_error
elsif response.commit_error.presence elsif response.commit_error.presence
raise Gitlab::Git::CommitError, response.commit_error raise Gitlab::Git::CommitError, response.commit_error
elsif response.create_tree_error.presence elsif response.create_tree_error.presence
......
...@@ -32,6 +32,8 @@ module Support ...@@ -32,6 +32,8 @@ module Support
allow(ENV).to receive(:[]).and_call_original allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:key?).and_call_original allow(ENV).to receive(:key?).and_call_original
allow(ENV).to receive(:fetch).and_call_original allow(ENV).to receive(:fetch).and_call_original
# Prevent secrets from leaking in CI
allow(ENV).to receive(:inspect).and_return([])
add_stubbed_value(STUBBED_KEY, true) add_stubbed_value(STUBBED_KEY, true)
end end
end end
......
...@@ -562,7 +562,7 @@ describe UploadsController do ...@@ -562,7 +562,7 @@ describe UploadsController do
end end
context 'original filename or a version filename must match' do context 'original filename or a version filename must match' do
let!(:appearance) { create :appearance, favicon: fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') } let!(:appearance) { create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
context 'has a valid filename on the original file' do context 'has a valid filename on the original file' do
it 'successfully returns the file' do it 'successfully returns the file' do
......
...@@ -38,7 +38,7 @@ feature 'Master deletes tag' do ...@@ -38,7 +38,7 @@ feature 'Master deletes tag' do
context 'when Gitaly operation_user_delete_tag feature is enabled' do context 'when Gitaly operation_user_delete_tag feature is enabled' do
before do before do
allow_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rm_tag) allow_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rm_tag)
.and_raise(Gitlab::Git::HooksService::PreReceiveError, 'Do not delete tags') .and_raise(Gitlab::Git::PreReceiveError, 'Do not delete tags')
end end
scenario 'shows the error message' do scenario 'shows the error message' do
...@@ -51,7 +51,7 @@ feature 'Master deletes tag' do ...@@ -51,7 +51,7 @@ feature 'Master deletes tag' do
context 'when Gitaly operation_user_delete_tag feature is disabled', :skip_gitaly_mock do context 'when Gitaly operation_user_delete_tag feature is disabled', :skip_gitaly_mock do
before do before do
allow_any_instance_of(Gitlab::Git::HooksService).to receive(:execute) allow_any_instance_of(Gitlab::Git::HooksService).to receive(:execute)
.and_raise(Gitlab::Git::HooksService::PreReceiveError, 'Do not delete tags') .and_raise(Gitlab::Git::PreReceiveError, 'Do not delete tags')
end end
scenario 'shows the error message' do scenario 'shows the error message' do
......
...@@ -45,12 +45,15 @@ describe('IDE pipelines list', () => { ...@@ -45,12 +45,15 @@ describe('IDE pipelines list', () => {
setTimeout(done); setTimeout(done);
}); });
afterEach(() => { afterEach(done => {
vm.$store.dispatch('pipelines/stopPipelinePolling');
vm.$store.dispatch('pipelines/clearEtagPoll');
vm.$destroy(); vm.$destroy();
mock.restore(); mock.restore();
vm.$store
.dispatch('pipelines/stopPipelinePolling')
.then(() => vm.$store.dispatch('pipelines/clearEtagPoll'))
.then(done)
.catch(done.fail);
}); });
it('renders pipeline data', () => { it('renders pipeline data', () => {
......
...@@ -199,28 +199,39 @@ describe('IDE merge requests actions', () => { ...@@ -199,28 +199,39 @@ describe('IDE merge requests actions', () => {
}); });
it('commits reset mutations and actions', done => { it('commits reset mutations and actions', done => {
testAction( const commit = jasmine.createSpy();
openMergeRequest, const dispatch = jasmine.createSpy().and.returnValue(Promise.resolve());
{ projectPath: 'gitlab-org/gitlab-ce', id: '1' }, openMergeRequest({ commit, dispatch }, { projectPath: 'gitlab-org/gitlab-ce', id: '1' });
mockedState,
[ setTimeout(() => {
{ type: 'CLEAR_PROJECTS' }, expect(commit.calls.argsFor(0)).toEqual(['CLEAR_PROJECTS', null, { root: true }]);
{ type: 'SET_CURRENT_MERGE_REQUEST', payload: '1' }, expect(commit.calls.argsFor(1)).toEqual(['SET_CURRENT_MERGE_REQUEST', '1', { root: true }]);
{ type: 'RESET_OPEN_FILES' }, expect(commit.calls.argsFor(2)).toEqual(['RESET_OPEN_FILES', null, { root: true }]);
],
[ expect(dispatch.calls.argsFor(0)).toEqual([
{ type: 'pipelines/stopPipelinePolling' }, 'pipelines/resetLatestPipeline',
{ type: 'pipelines/clearEtagPoll' }, null,
{ type: 'pipelines/resetLatestPipeline' }, { root: true },
{ type: 'setCurrentBranchId', payload: '' }, ]);
], expect(dispatch.calls.argsFor(1)).toEqual(['setCurrentBranchId', '', { root: true }]);
done, expect(dispatch.calls.argsFor(2)).toEqual([
); 'pipelines/stopPipelinePolling',
null,
{ root: true },
]);
expect(dispatch.calls.argsFor(3)).toEqual([
'pipelines/clearEtagPoll',
null,
{ root: true },
]);
done();
});
}); });
it('pushes new route', () => { it('pushes new route', () => {
openMergeRequest( openMergeRequest(
{ commit() {}, dispatch() {} }, { commit() {}, dispatch: () => Promise.resolve() },
{ projectPath: 'gitlab-org/gitlab-ce', id: '1' }, { projectPath: 'gitlab-org/gitlab-ce', id: '1' },
); );
......
import Vue from 'vue'; import Vue from 'vue';
import authorTimeComponent from '~/vue_merge_request_widget/components/mr_widget_author_time.vue'; import MrWidgetAuthorTime from '~/vue_merge_request_widget/components/mr_widget_author_time.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('MRWidgetAuthorTime', () => { describe('MrWidgetAuthorTime', () => {
let vm; let vm;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(authorTimeComponent); const Component = Vue.extend(MrWidgetAuthorTime);
vm = mountComponent(Component, { vm = mountComponent(Component, {
actionText: 'Merged by', actionText: 'Merged by',
...@@ -34,7 +34,7 @@ describe('MRWidgetAuthorTime', () => { ...@@ -34,7 +34,7 @@ describe('MRWidgetAuthorTime', () => {
}); });
it('renders provided time', () => { it('renders provided time', () => {
expect(vm.$el.querySelector('time').getAttribute('title')).toEqual('2017-03-23T23:02:00.807Z'); expect(vm.$el.querySelector('time').getAttribute('data-original-title')).toEqual('2017-03-23T23:02:00.807Z');
expect(vm.$el.querySelector('time').textContent.trim()).toEqual('12 hours ago'); expect(vm.$el.querySelector('time').textContent.trim()).toEqual('12 hours ago');
}); });
}); });
...@@ -186,7 +186,7 @@ describe('MRWidgetMerged', () => { ...@@ -186,7 +186,7 @@ describe('MRWidgetMerged', () => {
it('should use mergedEvent mergedAt as tooltip title', () => { it('should use mergedEvent mergedAt as tooltip title', () => {
expect( expect(
vm.$el.querySelector('time').getAttribute('title'), vm.$el.querySelector('time').getAttribute('data-original-title'),
).toBe('Jan 24, 2018 1:02pm GMT+0000'); ).toBe('Jan 24, 2018 1:02pm GMT+0000');
}); });
}); });
...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Favicon, :request_store do ...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Favicon, :request_store do
end end
it 'uses the custom favicon if a favicon appearance is present' do it 'uses the custom favicon if a favicon appearance is present' do
create :appearance, favicon: fixture_file_upload(Rails.root.join('spec/fixtures/dk.png')) create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
expect(described_class.main).to match %r{/uploads/-/system/appearance/favicon/\d+/favicon_main_dk.png} expect(described_class.main).to match %r{/uploads/-/system/appearance/favicon/\d+/favicon_main_dk.png}
end end
end end
......
...@@ -9,24 +9,31 @@ describe Gitlab::Git::Hook do ...@@ -9,24 +9,31 @@ describe Gitlab::Git::Hook do
end end
describe "#trigger" do describe "#trigger" do
let(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw_repository } let(:repository) { project.repository.raw_repository }
let(:repo_path) { repository.path } let(:repo_path) { repository.path }
let(:hooks_dir) { File.join(repo_path, 'hooks') }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:gl_id) { Gitlab::GlId.gl_id(user) } let(:gl_id) { Gitlab::GlId.gl_id(user) }
let(:gl_username) { user.username } let(:gl_username) { user.username }
def create_hook(name) def create_hook(name)
FileUtils.mkdir_p(File.join(repo_path, 'hooks')) FileUtils.mkdir_p(hooks_dir)
File.open(File.join(repo_path, 'hooks', name), 'w', 0755) do |f| hook_path = File.join(hooks_dir, name)
f.write('exit 0') File.open(hook_path, 'w', 0755) do |f|
f.write(<<~HOOK)
#!/bin/sh
exit 0
HOOK
end end
end end
def create_failing_hook(name) def create_failing_hook(name)
FileUtils.mkdir_p(File.join(repo_path, 'hooks')) FileUtils.mkdir_p(hooks_dir)
File.open(File.join(repo_path, 'hooks', name), 'w', 0755) do |f| hook_path = File.join(hooks_dir, name)
f.write(<<-HOOK) File.open(hook_path, 'w', 0755) do |f|
f.write(<<~HOOK)
#!/bin/sh
echo 'regular message from the hook' echo 'regular message from the hook'
echo 'error message from the hook' 1>&2 echo 'error message from the hook' 1>&2
echo 'error message from the hook line 2' 1>&2 echo 'error message from the hook line 2' 1>&2
...@@ -38,7 +45,7 @@ describe Gitlab::Git::Hook do ...@@ -38,7 +45,7 @@ describe Gitlab::Git::Hook do
['pre-receive', 'post-receive', 'update'].each do |hook_name| ['pre-receive', 'post-receive', 'update'].each do |hook_name|
context "when triggering a #{hook_name} hook" do context "when triggering a #{hook_name} hook" do
context "when the hook is successful" do context "when the hook is successful" do
let(:hook_path) { File.join(repo_path, 'hooks', hook_name) } let(:hook_path) { File.join(hooks_dir, hook_name) }
let(:gl_repository) { Gitlab::GlRepository.gl_repository(project, false) } let(:gl_repository) { Gitlab::GlRepository.gl_repository(project, false) }
let(:env) do let(:env) do
{ {
...@@ -76,7 +83,7 @@ describe Gitlab::Git::Hook do ...@@ -76,7 +83,7 @@ describe Gitlab::Git::Hook do
status, errors = hook.trigger(gl_id, gl_username, blank, blank, ref) status, errors = hook.trigger(gl_id, gl_username, blank, blank, ref)
expect(status).to be false expect(status).to be false
expect(errors).to eq("error message from the hook<br>error message from the hook line 2<br>") expect(errors).to eq("error message from the hook\nerror message from the hook line 2\n")
end end
end end
end end
......
...@@ -26,24 +26,24 @@ describe Gitlab::Git::HooksService, seed_helper: true do ...@@ -26,24 +26,24 @@ describe Gitlab::Git::HooksService, seed_helper: true do
context 'when pre-receive hook failed' do context 'when pre-receive hook failed' do
it 'does not call post-receive hook' do it 'does not call post-receive hook' do
expect(service).to receive(:run_hook).with('pre-receive').and_return([false, '']) expect(service).to receive(:run_hook).with('pre-receive').and_return([false, 'hello world'])
expect(service).not_to receive(:run_hook).with('post-receive') expect(service).not_to receive(:run_hook).with('post-receive')
expect do expect do
service.execute(user, repository, blankrev, newrev, ref) service.execute(user, repository, blankrev, newrev, ref)
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError, 'hello world')
end end
end end
context 'when update hook failed' do context 'when update hook failed' do
it 'does not call post-receive hook' do it 'does not call post-receive hook' do
expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil]) expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil])
expect(service).to receive(:run_hook).with('update').and_return([false, '']) expect(service).to receive(:run_hook).with('update').and_return([false, 'hello world'])
expect(service).not_to receive(:run_hook).with('post-receive') expect(service).not_to receive(:run_hook).with('post-receive')
expect do expect do
service.execute(user, repository, blankrev, newrev, ref) service.execute(user, repository, blankrev, newrev, ref)
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError, 'hello world')
end end
end end
end end
......
require 'spec_helper'
describe Gitlab::Git::PreReceiveError do
it 'makes its message HTML-friendly' do
ex = described_class.new("hello\nworld\n")
expect(ex.message).to eq('hello<br>world<br>')
end
end
...@@ -48,7 +48,7 @@ describe Gitlab::GitalyClient::OperationService do ...@@ -48,7 +48,7 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response) .and_return(response)
expect { subject }.to raise_error( expect { subject }.to raise_error(
Gitlab::Git::HooksService::PreReceiveError, "something failed") Gitlab::Git::PreReceiveError, "something failed")
end end
end end
end end
...@@ -85,7 +85,7 @@ describe Gitlab::GitalyClient::OperationService do ...@@ -85,7 +85,7 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response) .and_return(response)
expect { subject }.to raise_error( expect { subject }.to raise_error(
Gitlab::Git::HooksService::PreReceiveError, "something failed") Gitlab::Git::PreReceiveError, "something failed")
end end
end end
end end
......
...@@ -475,7 +475,7 @@ describe JiraService do ...@@ -475,7 +475,7 @@ describe JiraService do
end end
it 'includes returns the custom favicon' do it 'includes returns the custom favicon' do
create :appearance, favicon: fixture_file_upload(Rails.root.join('spec/fixtures/dk.png')) create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
props = described_class.new.send(:build_remote_link_props, url: 'http://example.com', title: 'title') props = described_class.new.send(:build_remote_link_props, url: 'http://example.com', title: 'title')
expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/uploads/-/system/appearance/favicon/\d+/favicon_main_dk.png$} expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/uploads/-/system/appearance/favicon/\d+/favicon_main_dk.png$}
......
...@@ -286,6 +286,7 @@ describe Project do ...@@ -286,6 +286,7 @@ describe Project do
expect(project2.errors[:import_url].first).to include('Username needs to start with an alphanumeric character') expect(project2.errors[:import_url].first).to include('Username needs to start with an alphanumeric character')
end end
<<<<<<< HEAD
it 'creates import state when mirror gets enabled' do it 'creates import state when mirror gets enabled' do
project2 = create(:project) project2 = create(:project)
...@@ -294,6 +295,8 @@ describe Project do ...@@ -294,6 +295,8 @@ describe Project do
end.to change { ProjectImportState.where(project: project2).count }.from(0).to(1) end.to change { ProjectImportState.where(project: project2).count }.from(0).to(1)
end end
=======
>>>>>>> upstream/master
describe 'project pending deletion' do describe 'project pending deletion' do
let!(:project_pending_deletion) do let!(:project_pending_deletion) do
create(:project, create(:project,
......
...@@ -1195,7 +1195,7 @@ describe Repository do ...@@ -1195,7 +1195,7 @@ describe Repository do
Gitlab::Git::OperationService.new(git_user, repository.raw_repository).with_branch('feature') do Gitlab::Git::OperationService.new(git_user, repository.raw_repository).with_branch('feature') do
new_rev new_rev
end end
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError)
end end
end end
...@@ -1938,13 +1938,13 @@ describe Repository do ...@@ -1938,13 +1938,13 @@ describe Repository do
context 'when pre hooks failed' do context 'when pre hooks failed' do
before do before do
allow_any_instance_of(Gitlab::GitalyClient::OperationService) allow_any_instance_of(Gitlab::GitalyClient::OperationService)
.to receive(:user_delete_branch).and_raise(Gitlab::Git::HooksService::PreReceiveError) .to receive(:user_delete_branch).and_raise(Gitlab::Git::PreReceiveError)
end end
it 'gets an error and does not delete the branch' do it 'gets an error and does not delete the branch' do
expect do expect do
repository.rm_branch(user, 'feature') repository.rm_branch(user, 'feature')
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError)
expect(repository.find_branch('feature')).not_to be_nil expect(repository.find_branch('feature')).not_to be_nil
end end
...@@ -1980,7 +1980,7 @@ describe Repository do ...@@ -1980,7 +1980,7 @@ describe Repository do
expect do expect do
repository.rm_branch(user, 'feature') repository.rm_branch(user, 'feature')
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError)
end end
it 'does not delete the branch' do it 'does not delete the branch' do
...@@ -1988,7 +1988,7 @@ describe Repository do ...@@ -1988,7 +1988,7 @@ describe Repository do
expect do expect do
repository.rm_branch(user, 'feature') repository.rm_branch(user, 'feature')
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end.to raise_error(Gitlab::Git::PreReceiveError)
expect(repository.find_branch('feature')).not_to be_nil expect(repository.find_branch('feature')).not_to be_nil
end end
end end
......
...@@ -72,7 +72,7 @@ describe MergeRequests::FfMergeService do ...@@ -72,7 +72,7 @@ describe MergeRequests::FfMergeService do
it 'logs and saves error if there is an PreReceiveError exception' do it 'logs and saves error if there is an PreReceiveError exception' do
error_message = 'error message' error_message = 'error message'
allow(service).to receive(:repository).and_raise(Gitlab::Git::HooksService::PreReceiveError, error_message) allow(service).to receive(:repository).and_raise(Gitlab::Git::PreReceiveError, error_message)
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
service.execute(merge_request) service.execute(merge_request)
......
...@@ -226,7 +226,7 @@ describe MergeRequests::MergeService do ...@@ -226,7 +226,7 @@ describe MergeRequests::MergeService do
it 'logs and saves error if there is an PreReceiveError exception' do it 'logs and saves error if there is an PreReceiveError exception' do
error_message = 'error message' error_message = 'error message'
allow(service).to receive(:repository).and_raise(Gitlab::Git::HooksService::PreReceiveError, error_message) allow(service).to receive(:repository).and_raise(Gitlab::Git::PreReceiveError, error_message)
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
service.execute(merge_request) service.execute(merge_request)
......
...@@ -41,7 +41,7 @@ describe Tags::CreateService do ...@@ -41,7 +41,7 @@ describe Tags::CreateService do
it 'returns an error' do it 'returns an error' do
expect(repository).to receive(:add_tag) expect(repository).to receive(:add_tag)
.with(user, 'v1.1.0', 'master', 'Foo') .with(user, 'v1.1.0', 'master', 'Foo')
.and_raise(Gitlab::Git::HooksService::PreReceiveError, 'something went wrong') .and_raise(Gitlab::Git::PreReceiveError, 'something went wrong')
response = service.execute('v1.1.0', 'master', 'Foo') response = service.execute('v1.1.0', 'master', 'Foo')
......
...@@ -10,7 +10,7 @@ RSpec.describe FaviconUploader do ...@@ -10,7 +10,7 @@ RSpec.describe FaviconUploader do
end end
def upload_fixture(filename) def upload_fixture(filename)
fixture_file_upload(Rails.root.join('spec', 'fixtures', filename)) fixture_file_upload("spec/fixtures/#{filename}")
end end
context 'versions' do context 'versions' do
......
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