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
ce4ff82e
Commit
ce4ff82e
authored
Aug 29, 2018
by
Sean McGivern
Committed by
Lin Jen-Shin
Sep 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove EE-specific code from Mentionable
parent
7a0008e4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
6 deletions
+57
-6
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+7
-2
app/models/concerns/mentionable/reference_regexes.rb
app/models/concerns/mentionable/reference_regexes.rb
+11
-4
app/models/epic.rb
app/models/epic.rb
+4
-0
ee/app/models/concerns/ee/mentionable.rb
ee/app/models/concerns/ee/mentionable.rb
+14
-0
ee/app/models/concerns/ee/mentionable/reference_regexes.rb
ee/app/models/concerns/ee/mentionable/reference_regexes.rb
+21
-0
No files found.
app/models/concerns/mentionable.rb
View file @
ce4ff82e
...
...
@@ -10,6 +10,8 @@
module
Mentionable
extend
ActiveSupport
::
Concern
prepend
EE
::
Mentionable
class_methods
do
# Indicate which attributes of the Mentionable to search for GFM references.
def
attr_mentionable
(
attr
,
options
=
{})
...
...
@@ -86,12 +88,11 @@ module Mentionable
return
[]
unless
matches_cross_reference_regex?
refs
=
all_references
(
current_user
)
refs
=
(
refs
.
issues
+
refs
.
merge_requests
+
refs
.
commits
+
refs
.
epics
)
# 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 +135,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
...
...
app/models/concerns/mentionable/reference_regexes.rb
View file @
ce4ff82e
...
...
@@ -2,17 +2,24 @@
module
Mentionable
module
ReferenceRegexes
prepend
EE
::
Mentionable
::
ReferenceRegexes
def
self
.
reference_pattern
(
link_patterns
,
issue_pattern
)
Regexp
.
union
(
link_patterns
,
issue_pattern
,
Epic
.
reference_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
,
Epic
].
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 @
ce4ff82e
...
...
@@ -5,6 +5,10 @@
class
Epic
<
ActiveRecord
::
Base
prepend
EE
::
Epic
def
self
.
link_reference_pattern
nil
end
def
self
.
reference_prefix
'&'
end
...
...
ee/app/models/concerns/ee/mentionable.rb
0 → 100644
View file @
ce4ff82e
# frozen_string_literal: true
module
EE
module
Mentionable
extend
::
Gitlab
::
Utils
::
Override
private
override
:extracted_mentionables
def
extracted_mentionables
(
refs
)
super
+
refs
.
epics
end
end
end
ee/app/models/concerns/ee/mentionable/reference_regexes.rb
0 → 100644
View file @
ce4ff82e
# frozen_string_literal: true
module
EE
module
Mentionable
module
ReferenceRegexes
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:other_patterns
def
other_patterns
[
::
Epic
.
reference_pattern
,
*
super
]
end
end
end
end
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