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

Add latest changes from gitlab-org/gitlab@master

parent 6763d278
No related branches found
No related tags found
No related merge requests found
Showing
with 137 additions and 96 deletions
Loading
Loading
@@ -750,7 +750,7 @@ GEM
orm_adapter (0.5.0)
os (1.0.0)
parallel (1.19.1)
parser (2.6.5.0)
parser (2.7.0.4)
ast (~> 2.4.0)
parslet (1.8.2)
peek (1.1.0)
Loading
Loading
@@ -1094,13 +1094,13 @@ GEM
uniform_notifier (1.13.0)
unleash (0.1.5)
murmurhash3 (~> 0.1.6)
unparser (0.4.5)
unparser (0.4.7)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
concord (~> 0.1.5)
diff-lcs (~> 1.3)
equalizer (~> 0.0.9)
parser (~> 2.6.3)
parser (>= 2.6.5)
procto (~> 0.0.2)
validate_email (0.1.6)
activemodel (>= 3.0)
Loading
Loading
<script>
import { GlDropdown, GlDropdownDivider, GlDropdownHeader, GlDropdownItem } from '@gitlab/ui';
import { joinPaths } from '~/lib/utils/url_utility';
import { joinPaths, escapeFileUrl } from '~/lib/utils/url_utility';
import { __ } from '../../locale';
import Icon from '../../vue_shared/components/icon.vue';
import getRefMixin from '../mixins/get_ref';
Loading
Loading
@@ -103,7 +103,7 @@ export default {
.filter(p => p !== '')
.reduce(
(acc, name, i) => {
const path = joinPaths(i > 0 ? acc[i].path : '', encodeURIComponent(name));
const path = joinPaths(i > 0 ? acc[i].path : '', escapeFileUrl(name));
 
return acc.concat({
name,
Loading
Loading
<script>
import { escapeRegExp } from 'lodash';
import { GlBadge, GlLink, GlSkeletonLoading, GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility';
import { visitUrl, escapeFileUrl } from '~/lib/utils/url_utility';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import Icon from '~/vue_shared/components/icon.vue';
import { getIconName } from '../../utils/icon';
Loading
Loading
@@ -92,7 +92,7 @@ export default {
computed: {
routerLinkTo() {
return this.isFolder
? { path: `/-/tree/${escape(this.ref)}/${encodeURIComponent(this.path)}` }
? { path: `/-/tree/${escape(this.ref)}/${escapeFileUrl(this.path)}` }
: null;
},
iconName() {
Loading
Loading
Loading
Loading
@@ -42,11 +42,13 @@ module Projects
def schedule_import(params)
import_data = @project.create_or_update_import_data(data: {}).becomes(JiraImportData)
 
import_data << JiraImportData::JiraProjectDetails.new(
jira_project_details = JiraImportData::JiraProjectDetails.new(
params[:jira_project_key],
Time.now.strftime('%Y-%m-%d %H:%M:%S'),
{ user_id: current_user.id, name: current_user.name }
)
import_data << jira_project_details
import_data.force_import!
 
@project.import_type = 'jira'
@project.import_state.schedule if @project.save
Loading
Loading
Loading
Loading
@@ -344,8 +344,8 @@ module BlobHelper
 
def show_suggest_pipeline_creation_celebration?
experiment_enabled?(:suggest_pipeline) &&
@blob.auxiliary_viewer.valid?(project: @project, sha: @commit.sha, user: current_user) &&
@blob.path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] &&
@blob.auxiliary_viewer.valid?(project: @project, sha: @commit.sha, user: current_user) &&
@project.uses_default_ci_config? &&
cookies[suggest_pipeline_commit_cookie_name].present?
end
Loading
Loading
Loading
Loading
@@ -45,6 +45,6 @@ module CiVariablesHelper
end
 
def ci_variable_maskable_regex
Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/')
Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/')
end
end
Loading
Loading
@@ -3,9 +3,9 @@
module Ci
class GroupVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Ci::HasVariable
include Presentable
include Maskable
include Ci::Maskable
 
belongs_to :group, class_name: "::Group"
 
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module Ci
class JobVariable < ApplicationRecord
extend Gitlab::Ci::Model
include NewHasVariable
include Ci::NewHasVariable
include BulkInsertSafe
 
belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module Ci
class PipelineScheduleVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Ci::HasVariable
 
belongs_to :pipeline_schedule
 
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module Ci
class PipelineVariable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Ci::HasVariable
 
belongs_to :pipeline
 
Loading
Loading
Loading
Loading
@@ -3,9 +3,9 @@
module Ci
class Variable < ApplicationRecord
extend Gitlab::Ci::Model
include HasVariable
include Ci::HasVariable
include Presentable
include Maskable
include Ci::Maskable
prepend HasEnvironmentScope
 
belongs_to :project
Loading
Loading
# frozen_string_literal: true
module Ci
module HasVariable
extend ActiveSupport::Concern
included do
enum variable_type: {
env_var: 1,
file: 2
}
validates :key,
presence: true,
length: { maximum: 255 },
format: { with: /\A[a-zA-Z0-9_]+\z/,
message: "can contain only letters, digits and '_'." }
scope :order_key_asc, -> { reorder(key: :asc) }
attr_encrypted :value,
mode: :per_attribute_iv_and_salt,
insecure_mode: true,
key: Settings.attr_encrypted_db_key_base,
algorithm: 'aes-256-cbc'
def key=(new_key)
super(new_key.to_s.strip)
end
end
def to_runner_variable
{ key: key, value: value, public: false, file: file? }
end
end
end
# frozen_string_literal: true
module Ci
module Maskable
extend ActiveSupport::Concern
# * Single line
# * No escape characters
# * No variables
# * No spaces
# * Minimal length of 8 characters
# * Characters must be from the Base64 alphabet (RFC4648) with the addition of @ and :
# * Absolutely no fun is allowed
REGEX = /\A[a-zA-Z0-9_+=\/@:-]{8,}\z/.freeze
included do
validates :masked, inclusion: { in: [true, false] }
validates :value, format: { with: REGEX }, if: :masked?
end
def to_runner_variable
super.merge(masked: masked?)
end
end
end
# frozen_string_literal: true
module Ci
module NewHasVariable
extend ActiveSupport::Concern
include Ci::HasVariable
included do
attr_encrypted :value,
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm',
key: Settings.attr_encrypted_db_key_base_32,
insecure_mode: false
end
end
end
# frozen_string_literal: true
module HasVariable
extend ActiveSupport::Concern
included do
enum variable_type: {
env_var: 1,
file: 2
}
validates :key,
presence: true,
length: { maximum: 255 },
format: { with: /\A[a-zA-Z0-9_]+\z/,
message: "can contain only letters, digits and '_'." }
scope :order_key_asc, -> { reorder(key: :asc) }
attr_encrypted :value,
mode: :per_attribute_iv_and_salt,
insecure_mode: true,
key: Settings.attr_encrypted_db_key_base,
algorithm: 'aes-256-cbc'
def key=(new_key)
super(new_key.to_s.strip)
end
end
def to_runner_variable
{ key: key, value: value, public: false, file: file? }
end
end
# frozen_string_literal: true
module Maskable
extend ActiveSupport::Concern
# * Single line
# * No escape characters
# * No variables
# * No spaces
# * Minimal length of 8 characters
# * Characters must be from the Base64 alphabet (RFC4648) with the addition of @ and :
# * Absolutely no fun is allowed
REGEX = /\A[a-zA-Z0-9_+=\/@:-]{8,}\z/.freeze
included do
validates :masked, inclusion: { in: [true, false] }
validates :value, format: { with: REGEX }, if: :masked?
end
def to_runner_variable
super.merge(masked: masked?)
end
end
# frozen_string_literal: true
module NewHasVariable
extend ActiveSupport::Concern
include HasVariable
included do
attr_encrypted :value,
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm',
key: Settings.attr_encrypted_db_key_base_32,
insecure_mode: false
end
end
Loading
Loading
@@ -3,17 +3,40 @@
class JiraImportData < ProjectImportData
JiraProjectDetails = Struct.new(:key, :scheduled_at, :scheduled_by)
 
FORCE_IMPORT_KEY = 'force-import'
def projects
return [] unless data
 
projects = data.dig('jira', 'projects').map do |p|
projects = data.dig('jira', 'projects')&.map do |p|
JiraProjectDetails.new(p['key'], p['scheduled_at'], p['scheduled_by'])
end
projects.sort_by { |jp| jp.scheduled_at }
projects&.sort_by { |jp| jp.scheduled_at } || []
end
 
def <<(project)
self.data ||= { jira: { projects: [] } }
self.data['jira']['projects'] << project.to_h.deep_stringify_keys!
self.data ||= { 'jira' => { 'projects' => [] } }
self.data['jira'] ||= { 'projects' => [] }
self.data['jira']['projects'] = [] if data['jira']['projects'].blank? || !data['jira']['projects'].is_a?(Array)
self.data['jira']['projects'] << project.to_h
self.data.deep_stringify_keys!
end
def force_import!
self.data ||= {}
self.data.deep_merge!({ 'jira' => { FORCE_IMPORT_KEY => true } })
self.data.deep_stringify_keys!
end
def force_import?
!!data&.dig('jira', FORCE_IMPORT_KEY) && !projects.blank?
end
def finish_import!
return if data&.dig('jira', FORCE_IMPORT_KEY).nil?
data['jira'].delete(FORCE_IMPORT_KEY)
end
end
Loading
Loading
@@ -868,6 +868,8 @@ class Project < ApplicationRecord
elsif gitlab_project_import?
# Do not retry on Import/Export until https://gitlab.com/gitlab-org/gitlab-foss/issues/26189 is solved.
RepositoryImportWorker.set(retry: false).perform_async(self.id)
elsif jira_import?
Gitlab::JiraImport::Stage::StartImportWorker.perform_async(self.id)
else
RepositoryImportWorker.perform_async(self.id)
end
Loading
Loading
@@ -900,7 +902,7 @@ class Project < ApplicationRecord
 
# This method is overridden in EE::Project model
def remove_import_data
import_data&.destroy
import_data&.destroy unless jira_import?
end
 
def ci_config_path=(value)
Loading
Loading
@@ -947,7 +949,7 @@ class Project < ApplicationRecord
end
 
def import?
external_import? || forked? || gitlab_project_import? || bare_repository_import?
external_import? || forked? || gitlab_project_import? || jira_import? || bare_repository_import?
end
 
def external_import?
Loading
Loading
@@ -962,6 +964,14 @@ class Project < ApplicationRecord
import_type == 'bare_repository'
end
 
def jira_import?
import_type == 'jira' && Feature.enabled?(:jira_issue_import, self)
end
def jira_force_import?
jira_import? && import_data&.becomes(JiraImportData)&.force_import?
end
def gitlab_project_import?
import_type == 'gitlab_project'
end
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ module Milestones
Milestone.joins(:issues)
.where(
issues: { project_id: project.id },
group_id: old_group.id
group_id: old_group.self_and_ancestors
)
end
# rubocop: enable CodeReuse/ActiveRecord
Loading
Loading
@@ -56,7 +56,7 @@ module Milestones
Milestone.joins(:merge_requests)
.where(
merge_requests: { target_project_id: project.id },
group_id: old_group.id
group_id: old_group.self_and_ancestors
)
end
# rubocop: enable CodeReuse/ActiveRecord
Loading
Loading
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