Skip to content
Snippets Groups Projects
Commit 6b9d3a4e authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 23288f62
No related branches found
No related tags found
No related merge requests found
Showing
with 153 additions and 125 deletions
Loading
Loading
@@ -23,7 +23,7 @@ module SpamCheckMethods
# attribute values.
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def spam_check(spammable, user)
SpamCheckService.new(
Spam::SpamCheckService.new(
spammable: spammable,
request: @request
).execute(
Loading
Loading
Loading
Loading
@@ -8,8 +8,18 @@ module Metrics
ALLOWED_FILE_TYPE = '.yml'
USER_DASHBOARDS_DIR = ::Metrics::Dashboard::ProjectDashboardService::DASHBOARD_ROOT
 
def self.allowed_dashboard_templates
@allowed_dashboard_templates ||= Set[::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH].freeze
class << self
def allowed_dashboard_templates
@allowed_dashboard_templates ||= Set[::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH].freeze
end
def sequences
@sequences ||= {
::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH => [::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::ProjectMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::Sorter].freeze
}.freeze
end
end
 
def execute
Loading
Loading
@@ -92,7 +102,9 @@ module Metrics
end
 
def new_dashboard_content
File.read(Rails.root.join(dashboard_template))
::Gitlab::Metrics::Dashboard::Processor
.new(project, raw_dashboard, sequence, {})
.process.deep_stringify_keys.to_yaml
end
 
def repository
Loading
Loading
@@ -106,6 +118,14 @@ module Metrics
result
end
end
def raw_dashboard
YAML.safe_load(File.read(Rails.root.join(dashboard_template)))
end
def sequence
self.class.sequences[dashboard_template]
end
end
end
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module Projects
matching_programming_languages = ensure_programming_languages(detection)
 
RepositoryLanguage.transaction do
project.repository_languages.where(programming_language_id: detection.deletions).delete_all
RepositoryLanguage.where(project_id: project.id, programming_language_id: detection.deletions).delete_all
 
detection.updates.each do |update|
RepositoryLanguage
Loading
Loading
Loading
Loading
@@ -20,6 +20,8 @@ module Projects
::Projects::MoveProjectAuthorizationsService.new(@project, @current_user)
.execute(source_project, remove_remaining_elements: remove_remaining_elements)
 
@project.save(touch: false)
success
end
end
Loading
Loading
Loading
Loading
@@ -13,8 +13,6 @@ module Projects
include Gitlab::ShellAdapter
TransferError = Class.new(StandardError)
 
attr_reader :new_namespace
def execute(new_namespace)
@new_namespace = new_namespace
 
Loading
Loading
@@ -39,6 +37,8 @@ module Projects
 
private
 
attr_reader :old_path, :new_path, :new_namespace
# rubocop: disable CodeReuse/ActiveRecord
def transfer(project)
@old_path = project.full_path
Loading
Loading
@@ -132,6 +132,8 @@ module Projects
end
 
def rollback_folder_move
return if project.hashed_storage?(:repository)
move_repo_folder(@new_path, @old_path)
move_repo_folder("#{@new_path}.wiki", "#{@old_path}.wiki")
end
Loading
Loading
# frozen_string_literal: true
module Spam
class SpamCheckService
include AkismetMethods
attr_accessor :spammable, :request, :options
attr_reader :spam_log
def initialize(spammable:, request:)
@spammable = spammable
@request = request
@options = {}
if @request
@options[:ip_address] = @request.env['action_dispatch.remote_ip'].to_s
@options[:user_agent] = @request.env['HTTP_USER_AGENT']
@options[:referrer] = @request.env['HTTP_REFERRER']
else
@options[:ip_address] = @spammable.ip_address
@options[:user_agent] = @spammable.user_agent
end
end
def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:)
if recaptcha_verified
# If it's a request which is already verified through recaptcha,
# update the spam log accordingly.
SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id)
else
# Otherwise, it goes to Akismet for spam check.
# If so, it assigns spammable object as "spam" and creates a SpamLog record.
possible_spam = check(api)
spammable.spam = possible_spam unless spammable.allow_possible_spam?
spammable.spam_log = spam_log
end
end
private
def check(api)
return unless request
return unless check_for_spam?
return unless akismet.spam?
create_spam_log(api)
true
end
def check_for_spam?
spammable.check_for_spam?
end
def create_spam_log(api)
@spam_log = SpamLog.create!(
{
user_id: spammable.author_id,
title: spammable.spam_title,
description: spammable.spam_description,
source_ip: options[:ip_address],
user_agent: options[:user_agent],
noteable_type: spammable.class.to_s,
via_api: api
}
)
end
end
end
# frozen_string_literal: true
class SpamCheckService
include AkismetMethods
attr_accessor :spammable, :request, :options
attr_reader :spam_log
def initialize(spammable:, request:)
@spammable = spammable
@request = request
@options = {}
if @request
@options[:ip_address] = @request.env['action_dispatch.remote_ip'].to_s
@options[:user_agent] = @request.env['HTTP_USER_AGENT']
@options[:referrer] = @request.env['HTTP_REFERRER']
else
@options[:ip_address] = @spammable.ip_address
@options[:user_agent] = @spammable.user_agent
end
end
def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:)
if recaptcha_verified
# If it's a request which is already verified through recaptcha,
# update the spam log accordingly.
SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id)
else
# Otherwise, it goes to Akismet for spam check.
# If so, it assigns spammable object as "spam" and creates a SpamLog record.
possible_spam = check(api)
spammable.spam = possible_spam unless spammable.allow_possible_spam?
spammable.spam_log = spam_log
end
end
private
def check(api)
return unless request
return unless check_for_spam?
return unless akismet.spam?
create_spam_log(api)
true
end
def check_for_spam?
spammable.check_for_spam?
end
def create_spam_log(api)
@spam_log = SpamLog.create!(
{
user_id: spammable.author_id,
title: spammable.spam_title,
description: spammable.spam_description,
source_ip: options[:ip_address],
user_agent: options[:user_agent],
noteable_type: spammable.class.to_s,
via_api: api
}
)
end
end
Loading
Loading
@@ -125,7 +125,7 @@ module ObjectStorage
 
included do
include AfterCommitQueue
after_save on: [:create, :update] do
after_save do
background_upload(changed_mounts)
end
end
Loading
Loading
Loading
Loading
@@ -49,13 +49,6 @@
= render 'projects/buttons/star'
= render 'projects/buttons/fork'
 
- if can?(current_user, :download_code, @project)
.project-clone-holder.d-inline-flex.d-md-none.btn-block
= render "shared/mobile_clone_panel"
.project-clone-holder.d-none.d-md-inline-flex
= render "projects/buttons/clone"
- if can?(current_user, :download_code, @project)
%nav.project-stats
.nav-links.quick-links
Loading
Loading
- project = project || @project
- dropdown_class = local_assigns.fetch(:dropdown_class, '')
 
.git-clone-holder.js-git-clone-holder.input-group
%a#clone-dropdown.input-group-text.btn.btn-primary.btn-xs.clone-dropdown-btn.qa-clone-dropdown{ href: '#', data: { toggle: 'dropdown' } }
.git-clone-holder.js-git-clone-holder
%a#clone-dropdown.btn.btn-primary.clone-dropdown-btn.qa-clone-dropdown{ href: '#', data: { toggle: 'dropdown' } }
%span.append-right-4.js-clone-dropdown-label
= _('Clone')
= sprite_icon("arrow-down", css_class: "icon")
%ul.p-3.dropdown-menu.dropdown-menu-right.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown.qa-clone-options
%ul.p-3.dropdown-menu.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown.qa-clone-options{ class: dropdown_class }
- if ssh_enabled?
%li
%label.label-bold
Loading
Loading
Loading
Loading
@@ -11,9 +11,14 @@
 
- if @project.can_current_user_push_code?
%p.append-bottom-0
= _('You can create files directly in GitLab using one of the following options.')
= _('You can get started by cloning the repository or start adding files to it with one of the following options.')
 
.project-buttons.qa-quick-actions
.project-clone-holder.d-block.d-md-none.mt-2.mr-2
= render "shared/mobile_clone_panel"
.project-clone-holder.d-none.d-md-inline-block.mt-2.mr-2.float-left
= render "projects/buttons/clone"
= render 'stat_anchor_list', anchors: @project.empty_repo_statistics_buttons
 
- if can?(current_user, :push_code, @project)
Loading
Loading
<% self.formats = ["html"] %>
<% self.formats = [:html] %>
 
<%= raw(
{
Loading
Loading
- add_to_breadcrumbs _("Releases"), project_releases_path(@project)
- page_title @release.name
#js-show-release-page{ data: { project_id: @project.id, tag_name: @release.tag } }
Loading
Loading
@@ -101,3 +101,9 @@
= render "projects/buttons/xcode_link"
 
= render 'projects/buttons/download', project: @project, ref: @ref
.project-clone-holder.d-block.d-md-none.mt-sm-2.mt-md-0>
= render "shared/mobile_clone_panel"
.project-clone-holder.d-none.d-md-inline-block>
= render "projects/buttons/clone", dropdown_class: 'dropdown-menu-right'
Loading
Loading
@@ -4,7 +4,7 @@
 
.btn-group.mobile-git-clone.js-mobile-git-clone.btn-block
= clipboard_button(button_text: default_clone_label, text: default_url_to_repo(project), hide_button_icon: true, class: "btn-primary flex-fill bold justify-content-center input-group-text clone-dropdown-btn js-clone-dropdown-label")
%button.btn.btn-primary.dropdown-toggle.js-dropdown-toggle.flex-grow-0.d-flex-center{ type: "button", data: { toggle: "dropdown" } }
%button.btn.btn-primary.dropdown-toggle.js-dropdown-toggle.flex-grow-0.d-flex-center.w-auto.ml-0{ type: "button", data: { toggle: "dropdown" } }
= sprite_icon("arrow-down", css_class: "dropdown-btn-icon icon")
%ul.dropdown-menu.dropdown-menu-selectable.dropdown-menu-right.clone-options-dropdown{ data: { dropdown: true } }
- if ssh_enabled?
Loading
Loading
Loading
Loading
@@ -26,49 +26,26 @@ module MailScheduler
end
 
def self.perform_async(*args)
super(*Arguments.serialize(args))
super(*ActiveJob::Arguments.serialize(args))
end
 
private
 
# If an argument is in the ActiveJob::Arguments::TYPE_WHITELIST list,
# This is copied over from https://github.com/rails/rails/blob/v6.0.1/activejob/lib/active_job/arguments.rb#L50
# because it is declared as a private constant
PERMITTED_TYPES = [NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass].freeze
private_constant :PERMITTED_TYPES
# If an argument is in the PERMITTED_TYPES list,
# it means the argument cannot be deserialized.
# Which means there's something wrong with our code.
def check_arguments!(args)
args.each do |arg|
if arg.class.in?(ActiveJob::Arguments::TYPE_WHITELIST)
if arg.class.in?(PERMITTED_TYPES)
raise(ArgumentError, "Argument `#{arg}` cannot be deserialized because of its type")
end
end
end
# Permit ActionController::Parameters for serializable Hash
#
# Port of
# https://github.com/rails/rails/commit/945fdd76925c9f615bf016717c4c8db2b2955357#diff-fc90ec41ef75be8b2259526fe1a8b663
module Arguments
include ActiveJob::Arguments
extend self
private
def serialize_argument(argument)
case argument
when -> (arg) { arg.respond_to?(:permitted?) }
serialize_hash(argument.to_h).tap do |result|
result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true)
end
else
super
end
end
end
# Make sure we remove this patch starting with Rails 6.0.
if Rails.version.start_with?('6.0')
raise <<~MSG
Please remove the patch `Arguments` module and use `ActiveJob::Arguments` again.
MSG
end
end
end
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
 
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
Loading
Loading
@@ -9,24 +8,25 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
 
chdir APP_ROOT do
# This script is a starting point to setup your application.
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.
 
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
 
# Install JavaScript dependencies if using Yarn
# Install JavaScript dependencies
# system('bin/yarn')
 
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end
 
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'
 
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
Loading
Loading
---
title: Remove unstaged and staged modification tooltip
merge_request: 23847
author:
type: fixed
---
title: Upgrade to Rails 6
merge_request: 19891
author:
type: other
---
title: Extends 'Duplicate dashboard' feature, by including custom metrics added to
GitLab-defined dashboards.
merge_request: 21923
author:
type: added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment