Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
375ce71b
Commit
375ce71b
authored
Aug 24, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
220b8426
b648ead0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
19 additions
and
97 deletions
+19
-97
app/assets/javascripts/ide/utils.js
app/assets/javascripts/ide/utils.js
+2
-2
app/models/concerns/cache_markdown_field.rb
app/models/concerns/cache_markdown_field.rb
+0
-33
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+0
-11
app/models/note.rb
app/models/note.rb
+0
-8
config/feature_flags/development/store_mentions_without_subtransaction.yml
...ags/development/store_mentions_without_subtransaction.yml
+0
-8
db/post_migrate/20210721122840_remove_seat_link_enabled_from_application_settings.rb
...840_remove_seat_link_enabled_from_application_settings.rb
+11
-0
db/schema_migrations/20210721122840
db/schema_migrations/20210721122840
+1
-0
db/structure.sql
db/structure.sql
+0
-1
spec/frontend/ide/utils_spec.js
spec/frontend/ide/utils_spec.js
+3
-0
spec/support/shared_examples/models/mentionable_shared_examples.rb
...ort/shared_examples/models/mentionable_shared_examples.rb
+2
-34
No files found.
app/assets/javascripts/ide/utils.js
View file @
375ce71b
...
...
@@ -44,8 +44,8 @@ const KNOWN_TYPES = [
];
export
function
isTextFile
({
name
,
raw
,
binary
,
content
,
mimeType
=
''
})
{
// some file objects already have a `binary` property set on them. If
true, return false
if
(
binary
)
return
false
;
// some file objects already have a `binary` property set on them. If
so, use it first
if
(
typeof
binary
===
'
boolean
'
)
return
!
binary
;
const
knownType
=
KNOWN_TYPES
.
find
((
type
)
=>
type
.
isMatch
(
mimeType
,
name
));
if
(
knownType
)
return
knownType
.
isText
;
...
...
app/models/concerns/cache_markdown_field.rb
View file @
375ce71b
...
...
@@ -160,39 +160,6 @@ module CacheMarkdownField
# We can only store mentions if the mentionable is a database object
return
unless
self
.
is_a?
(
ApplicationRecord
)
return
store_mentions_without_subtransaction!
if
Feature
.
enabled?
(
:store_mentions_without_subtransaction
,
default_enabled: :yaml
)
refs
=
all_references
(
self
.
author
)
references
=
{}
references
[
:mentioned_users_ids
]
=
refs
.
mentioned_user_ids
.
presence
references
[
:mentioned_groups_ids
]
=
refs
.
mentioned_group_ids
.
presence
references
[
:mentioned_projects_ids
]
=
refs
.
mentioned_project_ids
.
presence
# One retry is enough as next time `model_user_mention` should return the existing mention record,
# that threw the `ActiveRecord::RecordNotUnique` exception in first place.
self
.
class
.
safe_ensure_unique
(
retries:
1
)
do
# rubocop:disable Performance/ActiveRecordSubtransactionMethods
user_mention
=
model_user_mention
# this may happen due to notes polymorphism, so noteable_id may point to a record
# that no longer exists as we cannot have FK on noteable_id
break
if
user_mention
.
blank?
user_mention
.
mentioned_users_ids
=
references
[
:mentioned_users_ids
]
user_mention
.
mentioned_groups_ids
=
references
[
:mentioned_groups_ids
]
user_mention
.
mentioned_projects_ids
=
references
[
:mentioned_projects_ids
]
if
user_mention
.
has_mentions?
user_mention
.
save!
else
user_mention
.
destroy!
end
end
true
end
def
store_mentions_without_subtransaction!
identifier
=
user_mention_identifier
# this may happen due to notes polymorphism, so noteable_id may point to a record
...
...
app/models/concerns/mentionable.rb
View file @
375ce71b
...
...
@@ -217,17 +217,6 @@ module Mentionable
def
user_mention_association
association
(
:user_mentions
).
reflection
end
# User mention that is parsed from model description rather then its related notes.
# Models that have a description attribute like Issue, MergeRequest, Epic, Snippet may have such a user mention.
# Other mentionable models like Commit, DesignManagement::Design, will never have such record as those do not have
# a description attribute.
#
# Using this method followed by a call to *save* may result in *ActiveRecord::RecordNotUnique* exception
# in a multi-threaded environment. Make sure to use it within a *safe_ensure_unique* block.
def
model_user_mention
user_mentions
.
where
(
note_id:
nil
).
first_or_initialize
end
end
Mentionable
.
prepend_mod_with
(
'Mentionable'
)
app/models/note.rb
View file @
375ce71b
...
...
@@ -606,14 +606,6 @@ class Note < ApplicationRecord
private
# Using this method followed by a call to *save* may result in *ActiveRecord::RecordNotUnique* exception
# in a multi-threaded environment. Make sure to use it within a *safe_ensure_unique* block.
def
model_user_mention
return
if
user_mentions
.
is_a?
(
ActiveRecord
::
NullRelation
)
user_mentions
.
first_or_initialize
end
def
system_note_viewable_by?
(
user
)
return
true
unless
system_note_metadata
...
...
config/feature_flags/development/store_mentions_without_subtransaction.yml
deleted
100644 → 0
View file @
220b8426
---
name
:
store_mentions_without_subtransaction
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68433
rollout_issue_url
:
milestone
:
'
14.3'
type
:
development
group
:
group::project management
default_enabled
:
false
db/post_migrate/20210721122840_remove_seat_link_enabled_from_application_settings.rb
0 → 100644
View file @
375ce71b
# frozen_string_literal: true
class
RemoveSeatLinkEnabledFromApplicationSettings
<
ActiveRecord
::
Migration
[
6.1
]
def
up
remove_column
:application_settings
,
:seat_link_enabled
end
def
down
add_column
:application_settings
,
:seat_link_enabled
,
:boolean
,
null:
false
,
default:
true
end
end
db/schema_migrations/20210721122840
0 → 100644
View file @
375ce71b
483ef6f8ef379f39ecff32853c777c12c59d2858f061879c375ff6d429396167
\ No newline at end of file
db/structure.sql
View file @
375ce71b
...
...
@@ -9542,7 +9542,6 @@ CREATE TABLE application_settings (
email_restrictions_enabled boolean DEFAULT false NOT NULL,
email_restrictions text,
npm_package_requests_forwarding boolean DEFAULT true NOT NULL,
seat_link_enabled boolean DEFAULT true NOT NULL,
container_expiration_policies_enable_historic_entries boolean DEFAULT false NOT NULL,
issues_create_limit integer DEFAULT 0 NOT NULL,
push_rule_id bigint,
spec/frontend/ide/utils_spec.js
View file @
375ce71b
...
...
@@ -90,6 +90,9 @@ describe('WebIDE utils', () => {
it
(
'
returns true if there is a `binary` property already set on the file object
'
,
()
=>
{
expect
(
isTextFile
({
name
:
'
abc.txt
'
,
content
:
''
})).
toBe
(
true
);
expect
(
isTextFile
({
name
:
'
abc.txt
'
,
content
:
''
,
binary
:
true
})).
toBe
(
false
);
expect
(
isTextFile
({
name
:
'
abc.tex
'
,
content
:
'
éêė
'
})).
toBe
(
false
);
expect
(
isTextFile
({
name
:
'
abc.tex
'
,
content
:
'
éêė
'
,
binary
:
false
})).
toBe
(
true
);
});
});
...
...
spec/support/shared_examples/models/mentionable_shared_examples.rb
View file @
375ce71b
...
...
@@ -207,7 +207,7 @@ RSpec.shared_examples 'an editable mentionable' do
end
RSpec
.
shared_examples
'mentions in description'
do
|
mentionable_type
|
shared_examples
'when storing user mentions'
do
context
'when storing user mentions'
do
before
do
mentionable
.
store_mentions!
end
...
...
@@ -238,26 +238,10 @@ RSpec.shared_examples 'mentions in description' do |mentionable_type|
end
end
end
context
'when store_mentions_without_subtransaction is enabled'
do
before
do
stub_feature_flags
(
store_mentions_without_subtransaction:
true
)
end
it_behaves_like
'when storing user mentions'
end
context
'when store_mentions_without_subtransaction is disabled'
do
before
do
stub_feature_flags
(
store_mentions_without_subtransaction:
false
)
end
it_behaves_like
'when storing user mentions'
end
end
RSpec
.
shared_examples
'mentions in notes'
do
|
mentionable_type
|
shared_examples
'when mentionable notes contain mentions'
do
context
'when mentionable notes contain mentions'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
...
...
@@ -277,22 +261,6 @@ RSpec.shared_examples 'mentions in notes' do |mentionable_type|
expect
(
mentionable
.
referenced_groups
(
user
)).
to
eq
[
group
]
end
end
context
'when store_mentions_without_subtransaction is enabled'
do
before
do
stub_feature_flags
(
store_mentions_without_subtransaction:
true
)
end
it_behaves_like
'when mentionable notes contain mentions'
end
context
'when store_mentions_without_subtransaction is disabled'
do
before
do
stub_feature_flags
(
store_mentions_without_subtransaction:
false
)
end
it_behaves_like
'when mentionable notes contain mentions'
end
end
RSpec
.
shared_examples
'load mentions from DB'
do
|
mentionable_type
|
...
...
Write
Preview
Markdown
is supported
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