Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
ae44c014194c
Commit
ae44c014
authored
Mar 23, 2020
by
GitLab Bot
Browse files
Add latest changes from gitlab-org/gitlab@master
parent
19e45c4e32d1
Changes
86
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/boards/components/project_select.vue
View file @
ae44c014
...
...
@@ -64,6 +64,7 @@
this
.
groupId
,
term
,
{
search_namespaces
:
true
,
with_issues_enabled
:
true
,
with_shared
:
false
,
include_subgroups
:
true
,
...
...
app/assets/javascripts/project_select.js
View file @
ae44c014
...
...
@@ -54,6 +54,7 @@
this
.
groupId
,
query
.
term
,
{
search_namespaces
:
true
,
with_issues_enabled
:
this
.
withIssuesEnabled
,
with_merge_requests_enabled
:
this
.
withMergeRequestsEnabled
,
with_shared
:
this
.
withShared
,
...
...
app/assets/javascripts/repository/components/breadcrumbs.vue
View file @
ae44c014
...
...
@@ -134,7 +134,9 @@
},
{
attrs
:
{
href
:
`
${
this
.
newBlobPath
}
/
${
this
.
currentPath
?
escape
(
this
.
currentPath
)
:
''
}
`
,
href
:
`
${
this
.
newBlobPath
}
/
${
this
.
currentPath
?
encodeURIComponent
(
this
.
currentPath
)
:
''
}
`
,
class
:
'
qa-new-file-option
'
,
},
text
:
__
(
'
New file
'
),
...
...
app/assets/javascripts/repository/components/table/parent_row.vue
View file @
ae44c014
...
...
@@ -25,6 +25,6 @@
const
splitArray
=
this
.
path
.
split
(
'
/
'
);
splitArray
.
pop
();
return
splitArray
.
join
(
'
/
'
);
return
splitArray
.
map
(
p
=>
encodeURIComponent
(
p
)).
join
(
'
/
'
);
},
parentRoute
()
{
...
...
@@ -29,6 +29,6 @@
},
parentRoute
()
{
return
{
path
:
`/-/tree/
${
escape
(
this
.
commitRef
)}
/
${
escape
(
this
.
parentPath
)
}
`
};
return
{
path
:
`/-/tree/
${
escape
(
this
.
commitRef
)}
/
${
this
.
parentPath
}
`
};
},
},
methods
:
{
...
...
app/finders/autocomplete/move_to_project_finder.rb
View file @
ae44c014
...
...
@@ -25,7 +25,7 @@
def
execute
current_user
.
projects_where_can_admin_issues
.
optionally_search
(
search
)
.
optionally_search
(
search
,
include_namespace:
true
)
.
excluding_project
(
project_id
)
.
eager_load_namespace_and_owner
.
sorted_by_name_asc_limited
(
LIMIT
)
...
...
app/finders/projects_finder.rb
View file @
ae44c014
...
...
@@ -17,6 +17,7 @@
# tags: string[]
# personal: boolean
# search: string
# search_namespaces: boolean
# non_archived: boolean
# archived: 'only' or boolean
# min_access_level: integer
...
...
@@ -171,7 +172,7 @@
def
by_search
(
items
)
params
[
:search
]
||=
params
[
:name
]
params
[
:search
].
present?
?
items
.
search
(
params
[
:search
])
:
items
items
.
optionally_search
(
params
[
:search
],
include_namespace:
params
[
:search_namespaces
].
present?
)
end
def
by_deleted_status
(
items
)
...
...
app/models/concerns/alert_event_lifecycle.rb
0 → 100644
View file @
ae44c014
# frozen_string_literal: true
module
AlertEventLifecycle
extend
ActiveSupport
::
Concern
included
do
validates
:started_at
,
presence:
true
validates
:status
,
presence:
true
state_machine
:status
,
initial: :none
do
state
:none
,
value:
nil
state
:firing
,
value:
0
do
validates
:payload_key
,
presence:
true
validates
:ended_at
,
absence:
true
end
state
:resolved
,
value:
1
do
validates
:ended_at
,
presence:
true
end
event
:fire
do
transition
none: :firing
end
event
:resolve
do
transition
firing: :resolved
end
before_transition
to: :firing
do
|
alert_event
,
transition
|
started_at
=
transition
.
args
.
first
alert_event
.
started_at
=
started_at
end
before_transition
to: :resolved
do
|
alert_event
,
transition
|
ended_at
=
transition
.
args
.
first
alert_event
.
ended_at
=
ended_at
||
Time
.
current
end
end
scope
:firing
,
->
{
where
(
status:
status_value_for
(
:firing
))
}
scope
:resolved
,
->
{
where
(
status:
status_value_for
(
:resolved
))
}
scope
:count_by_project_id
,
->
{
group
(
:project_id
).
count
}
def
self
.
status_value_for
(
name
)
state_machines
[
:status
].
states
[
name
].
value
end
end
end
app/models/concerns/optionally_search.rb
View file @
ae44c014
...
...
@@ -12,8 +12,8 @@
end
# Optionally limits a result set to those matching the given search query.
def
optionally_search
(
query
=
nil
)
query
.
present?
?
search
(
query
)
:
all
def
optionally_search
(
query
=
nil
,
**
options
)
query
.
present?
?
search
(
query
,
**
options
)
:
all
end
end
end
app/models/concerns/protected_ref_access.rb
View file @
ae44c014
...
...
@@ -19,7 +19,6 @@
end
included
do
scope
:master
,
->
{
maintainer
}
# @deprecated
scope
:maintainer
,
->
{
where
(
access_level:
Gitlab
::
Access
::
MAINTAINER
)
}
scope
:developer
,
->
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
scope
:by_user
,
->
(
user
)
{
where
(
user_id:
user
)
}
...
...
app/models/concerns/select_for_project_authorization.rb
View file @
ae44c014
...
...
@@ -11,8 +11,5 @@
def
select_as_maintainer_for_project_authorization
select
([
"projects.id AS project_id"
,
"
#{
Gitlab
::
Access
::
MAINTAINER
}
AS access_level"
])
end
# @deprecated
alias_method
:select_as_master_for_project_authorization
,
:select_as_maintainer_for_project_authorization
end
end
app/models/environment.rb
View file @
ae44c014
...
...
@@ -14,6 +14,7 @@
has_many
:successful_deployments
,
->
{
success
},
class_name:
'Deployment'
has_many
:active_deployments
,
->
{
active
},
class_name:
'Deployment'
has_many
:prometheus_alerts
,
inverse_of: :environment
has_many
:self_managed_prometheus_alert_events
,
inverse_of: :environment
has_one
:last_deployment
,
->
{
success
.
order
(
'deployments.id DESC'
)
},
class_name:
'Deployment'
has_one
:last_deployable
,
through: :last_deployment
,
source:
'deployable'
,
source_type:
'CommitStatus'
...
...
app/models/group.rb
View file @
ae44c014
...
...
@@ -245,9 +245,6 @@
add_user
(
user
,
:maintainer
,
current_user:
current_user
)
end
# @deprecated
alias_method
:add_master
,
:add_maintainer
def
add_owner
(
user
,
current_user
=
nil
)
add_user
(
user
,
:owner
,
current_user:
current_user
)
end
...
...
@@ -274,9 +271,6 @@
::
ContainerRepository
.
for_group_and_its_subgroups
(
self
).
exists?
end
# @deprecated
alias_method
:has_master?
,
:has_maintainer?
# Check if user is a last owner of the group.
def
last_owner?
(
user
)
has_owner?
(
user
)
&&
members_with_parents
.
owners
.
size
==
1
...
...
app/models/lfs_objects_project.rb
View file @
ae44c014
# frozen_string_literal: true
class
LfsObjectsProject
<
ApplicationRecord
include
::
EachBatch
belongs_to
:project
belongs_to
:lfs_object
...
...
app/models/member.rb
View file @
ae44c014
...
...
@@ -76,6 +76,5 @@
scope
:developers
,
->
{
active
.
where
(
access_level:
DEVELOPER
)
}
scope
:maintainers
,
->
{
active
.
where
(
access_level:
MAINTAINER
)
}
scope
:non_guests
,
->
{
where
(
'members.access_level > ?'
,
GUEST
)
}
scope
:masters
,
->
{
maintainers
}
# @deprecated
scope
:owners
,
->
{
active
.
where
(
access_level:
OWNER
)
}
scope
:owners
,
->
{
active
.
where
(
access_level:
OWNER
)
}
scope
:owners_and_maintainers
,
->
{
active
.
where
(
access_level:
[
OWNER
,
MAINTAINER
])
}
...
...
@@ -81,5 +80,4 @@
scope
:owners_and_maintainers
,
->
{
active
.
where
(
access_level:
[
OWNER
,
MAINTAINER
])
}
scope
:owners_and_masters
,
->
{
owners_and_maintainers
}
# @deprecated
scope
:with_user
,
->
(
user
)
{
where
(
user:
user
)
}
scope
:with_source_id
,
->
(
source_id
)
{
where
(
source_id:
source_id
)
}
...
...
app/models/project.rb
View file @
ae44c014
...
...
@@ -255,6 +255,8 @@
has_many
:prometheus_metrics
has_many
:prometheus_alerts
,
inverse_of: :project
has_many
:prometheus_alert_events
,
inverse_of: :project
has_many
:self_managed_prometheus_alert_events
,
inverse_of: :project
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy
...
...
@@ -349,7 +351,6 @@
delegate
:members
,
to: :team
,
prefix:
true
delegate
:add_user
,
:add_users
,
to: :team
delegate
:add_guest
,
:add_reporter
,
:add_developer
,
:add_maintainer
,
:add_role
,
to: :team
delegate
:add_master
,
to: :team
# @deprecated
delegate
:group_runners_enabled
,
:group_runners_enabled
=
,
:group_runners_enabled?
,
to: :ci_cd_settings
delegate
:root_ancestor
,
to: :namespace
,
allow_nil:
true
delegate
:last_pipeline
,
to: :commit
,
allow_nil:
true
...
...
@@ -591,9 +592,9 @@
# case-insensitive.
#
# query - The search query as a String.
def
search
(
query
)
if
Feature
.
enabled?
(
:project_search_by_full_path
,
default_enabled:
true
)
joins
(
:route
).
fuzzy_search
(
query
,
[
Route
.
arel_table
[
:path
],
:name
,
:description
])
def
search
(
query
,
include_namespace:
false
)
if
include_namespace
&&
Feature
.
enabled?
(
:project_search_by_full_path
,
default_enabled:
true
)
joins
(
:route
).
fuzzy_search
(
query
,
[
Route
.
arel_table
[
:path
],
Route
.
arel_table
[
:name
]
,
:description
])
else
fuzzy_search
(
query
,
[
:path
,
:name
,
:description
])
end
...
...
app/models/project_group_link.rb
View file @
ae44c014
...
...
@@ -7,7 +7,6 @@
REPORTER
=
20
DEVELOPER
=
30
MAINTAINER
=
40
MASTER
=
MAINTAINER
# @deprecated
belongs_to
:project
belongs_to
:group
...
...
app/models/project_team.rb
View file @
ae44c014
...
...
@@ -25,9 +25,6 @@
add_user
(
user
,
:maintainer
,
current_user:
current_user
)
end
# @deprecated
alias_method
:add_master
,
:add_maintainer
def
add_role
(
user
,
role
,
current_user:
nil
)
public_send
(
:"add_
#{
role
}
"
,
user
,
current_user:
current_user
)
# rubocop:disable GitlabSecurity/PublicSend
end
...
...
@@ -98,9 +95,6 @@
@maintainers
||=
fetch_members
(
Gitlab
::
Access
::
MAINTAINER
)
end
# @deprecated
alias_method
:masters
,
:maintainers
def
owners
@owners
||=
if
group
...
...
@@ -156,9 +150,6 @@
max_member_access
(
user
.
id
)
==
Gitlab
::
Access
::
MAINTAINER
end
# @deprecated
alias_method
:master?
,
:maintainer?
# Checks if `user` is authorized for this project, with at least the
# `min_access_level` (if given).
def
member?
(
user
,
min_access_level
=
Gitlab
::
Access
::
GUEST
)
...
...
app/models/prometheus_alert_event.rb
0 → 100644
View file @
ae44c014
# frozen_string_literal: true
class
PrometheusAlertEvent
<
ApplicationRecord
include
AlertEventLifecycle
belongs_to
:project
,
optional:
false
,
validate:
true
,
inverse_of: :prometheus_alert_events
belongs_to
:prometheus_alert
,
optional:
false
,
validate:
true
,
inverse_of: :prometheus_alert_events
has_and_belongs_to_many
:related_issues
,
class_name:
'Issue'
,
join_table: :issues_prometheus_alert_events
# rubocop:disable Rails/HasAndBelongsToMany
validates
:payload_key
,
uniqueness:
{
scope: :prometheus_alert_id
}
validates
:started_at
,
presence:
true
delegate
:title
,
:prometheus_metric_id
,
to: :prometheus_alert
scope
:for_environment
,
->
(
environment
)
do
joins
(
:prometheus_alert
).
where
(
prometheus_alerts:
{
environment_id:
environment
})
end
scope
:with_prometheus_alert
,
->
{
includes
(
:prometheus_alert
)
}
def
self
.
last_by_project_id
ids
=
select
(
arel_table
[
:id
].
maximum
.
as
(
'id'
)).
group
(
:project_id
).
map
(
&
:id
)
with_prometheus_alert
.
find
(
ids
)
end
def
self
.
find_or_initialize_by_payload_key
(
project
,
alert
,
payload_key
)
find_or_initialize_by
(
project:
project
,
prometheus_alert:
alert
,
payload_key:
payload_key
)
end
def
self
.
find_by_payload_key
(
payload_key
)
find_by
(
payload_key:
payload_key
)
end
def
self
.
status_value_for
(
name
)
state_machines
[
:status
].
states
[
name
].
value
end
def
self
.
payload_key_for
(
gitlab_alert_id
,
started_at
)
plain
=
[
gitlab_alert_id
,
started_at
].
join
(
'/'
)
Digest
::
SHA1
.
hexdigest
(
plain
)
end
end
app/models/self_managed_prometheus_alert_event.rb
0 → 100644
View file @
ae44c014
# frozen_string_literal: true
class
SelfManagedPrometheusAlertEvent
<
ApplicationRecord
include
AlertEventLifecycle
belongs_to
:project
,
validate:
true
,
inverse_of: :self_managed_prometheus_alert_events
belongs_to
:environment
,
validate:
true
,
inverse_of: :self_managed_prometheus_alert_events
has_and_belongs_to_many
:related_issues
,
class_name:
'Issue'
,
join_table: :issues_self_managed_prometheus_alert_events
# rubocop:disable Rails/HasAndBelongsToMany
validates
:started_at
,
presence:
true
validates
:payload_key
,
uniqueness:
{
scope: :project_id
}
def
self
.
find_or_initialize_by_payload_key
(
project
,
payload_key
)
find_or_initialize_by
(
project:
project
,
payload_key:
payload_key
)
do
|
event
|
yield
event
if
block_given?
end
end
def
self
.
payload_key_for
(
started_at
,
alert_name
,
query_expression
)
plain
=
[
started_at
,
alert_name
,
query_expression
].
join
(
'/'
)
Digest
::
SHA1
.
hexdigest
(
plain
)
end
end
app/models/snippet_repository.rb
View file @
ae44c014
...
...
@@ -48,4 +48,5 @@
next_index
=
get_last_empty_file_index
+
1
files
.
each
do
|
file_entry
|
file_entry
[
:file_path
]
=
file_path_for
(
file_entry
,
next_index
)
{
next_index
+=
1
}
file_entry
[
:action
]
=
infer_action
(
file_entry
)
unless
file_entry
[
:action
]
...
...
@@ -51,2 +52,8 @@
file_entry
[
:action
]
=
infer_action
(
file_entry
)
unless
file_entry
[
:action
]
end
end
def
file_path_for
(
file_entry
,
next_index
)
return
file_entry
[
:file_path
]
if
file_entry
[
:file_path
].
present?
return
file_entry
[
:previous_path
]
if
reuse_previous_path?
(
file_entry
)
...
...
@@ -52,9 +59,14 @@
if
file_entry
[
:file_path
].
blank?
file_entry
[
:file_path
]
=
build_empty_file_name
(
next_index
)
next_index
+=
1
end
end
build_empty_file_name
(
next_index
).
tap
{
yield
}
end
# If the user removed the file_path and the previous_path
# matches the EMPTY_FILE_PATTERN, we don't need to
# rename the file and build a new empty file name,
# we can just reuse the existing file name
def
reuse_previous_path?
(
file_entry
)
file_entry
[
:file_path
].
blank?
&&
EMPTY_FILE_PATTERN
.
match?
(
file_entry
[
:previous_path
])
end
def
infer_action
(
file_entry
)
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment