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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
9357585e
Commit
9357585e
authored
Aug 29, 2018
by
Sean McGivern
Committed by
Lin Jen-Shin
Sep 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove EE-specific code from Mentionable
parent
896c89e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+10
-3
app/models/concerns/mentionable/reference_regexes.rb
app/models/concerns/mentionable/reference_regexes.rb
+9
-3
app/models/epic.rb
app/models/epic.rb
+4
-0
No files found.
app/models/concerns/mentionable.rb
View file @
9357585e
...
...
@@ -61,7 +61,7 @@ module Mentionable
cache_key:
[
self
,
attr
],
author:
author
,
skip_project_check:
skip_project_check?
)
)
.
merge
(
mentionable_params
)
extractor
.
analyze
(
text
,
options
)
end
...
...
@@ -86,12 +86,11 @@ module Mentionable
return
[]
unless
matches_cross_reference_regex?
refs
=
all_references
(
current_user
)
refs
=
(
refs
.
issues
+
refs
.
merge_requests
+
refs
.
commits
)
# We're using this method instead of Array diffing because that requires
# both of the object's `hash` values to be the same, which may not be the
# case for otherwise identical Commit objects.
refs
.
reject
{
|
ref
|
ref
==
local_reference
}
extracted_mentionables
(
refs
)
.
reject
{
|
ref
|
ref
==
local_reference
}
end
# Uses regex to quickly determine if mentionables might be referenced
...
...
@@ -134,6 +133,10 @@ module Mentionable
private
def
extracted_mentionables
(
refs
)
refs
.
issues
+
refs
.
merge_requests
+
refs
.
commits
end
# Returns a Hash of changed mentionable fields
#
# Preference is given to the `changes` Hash, but falls back to
...
...
@@ -161,4 +164,8 @@ module Mentionable
def
skip_project_check?
false
end
def
mentionable_params
{}
end
end
app/models/concerns/mentionable/reference_regexes.rb
View file @
9357585e
...
...
@@ -5,13 +5,19 @@ module Mentionable
def
self
.
reference_pattern
(
link_patterns
,
issue_pattern
)
Regexp
.
union
(
link_patterns
,
issue_pattern
,
Commit
.
reference_pattern
,
MergeRequest
.
reference_pattern
)
*
other_patterns
)
end
def
self
.
other_patterns
[
Commit
.
reference_pattern
,
MergeRequest
.
reference_pattern
]
end
DEFAULT_PATTERN
=
begin
issue_pattern
=
Issue
.
reference_pattern
link_patterns
=
Regexp
.
union
([
Issue
,
Commit
,
MergeRequest
].
map
(
&
:link_reference_pattern
)
)
link_patterns
=
Regexp
.
union
([
Issue
,
Commit
,
MergeRequest
,
Epic
].
map
(
&
:link_reference_pattern
).
compact
)
reference_pattern
(
link_patterns
,
issue_pattern
)
end
...
...
app/models/epic.rb
View file @
9357585e
...
...
@@ -3,6 +3,10 @@
# Placeholder class for model that is implemented in EE
# It reserves '&' as a reference prefix, but the table does not exists in CE
class
Epic
<
ActiveRecord
::
Base
def
self
.
link_reference_pattern
nil
end
def
self
.
reference_prefix
'&'
end
...
...
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