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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
27d952b1
Commit
27d952b1
authored
Oct 12, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cross-references originating from notes
parent
b0164771
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
20 deletions
+7
-20
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+2
-2
app/models/note.rb
app/models/note.rb
+3
-10
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+1
-7
app/services/notes/update_service.rb
app/services/notes/update_service.rb
+1
-1
No files found.
app/models/concerns/mentionable.rb
View file @
27d952b1
...
@@ -66,8 +66,8 @@ module Mentionable
...
@@ -66,8 +66,8 @@ module Mentionable
end
end
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
def
create_cross_references!
(
author
=
self
.
author
,
without
=
[])
def
create_cross_references!
(
author
=
self
.
author
,
without
=
[]
,
text
=
self
.
mentionable_text
)
refs
=
referenced_mentionables
(
author
)
refs
=
referenced_mentionables
(
author
,
text
)
# We're using this method instead of Array diffing because that requires
# 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
# both of the object's `hash` values to be the same, which may not be the
...
...
app/models/note.rb
View file @
27d952b1
...
@@ -62,7 +62,6 @@ class Note < ActiveRecord::Base
...
@@ -62,7 +62,6 @@ class Note < ActiveRecord::Base
serialize
:st_diff
serialize
:st_diff
before_create
:set_diff
,
if:
->
(
n
)
{
n
.
line_code
.
present?
}
before_create
:set_diff
,
if:
->
(
n
)
{
n
.
line_code
.
present?
}
after_update
:set_references
class
<<
self
class
<<
self
def
discussions_from_notes
(
notes
)
def
discussions_from_notes
(
notes
)
...
@@ -333,15 +332,13 @@ class Note < ActiveRecord::Base
...
@@ -333,15 +332,13 @@ class Note < ActiveRecord::Base
end
end
def
noteable_type_name
def
noteable_type_name
if
noteable_type
.
present?
noteable_type
.
downcase
if
noteable_type
.
present?
noteable_type
.
downcase
end
end
end
# FIXME: Hack for polymorphic associations with STI
# FIXME: Hack for polymorphic associations with STI
# For more information visit http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Polymorphic+Associations
# For more information visit http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Polymorphic+Associations
def
noteable_type
=
(
sT
ype
)
def
noteable_type
=
(
noteable_t
ype
)
super
(
sT
ype
.
to_s
.
classify
.
constantize
.
base_class
.
to_s
)
super
(
noteable_t
ype
.
to_s
.
classify
.
constantize
.
base_class
.
to_s
)
end
end
# Reset notes events cache
# Reset notes events cache
...
@@ -357,10 +354,6 @@ class Note < ActiveRecord::Base
...
@@ -357,10 +354,6 @@ class Note < ActiveRecord::Base
Event
.
reset_event_cache_for
(
self
)
Event
.
reset_event_cache_for
(
self
)
end
end
def
set_references
create_new_cross_references!
end
def
system?
def
system?
read_attribute
(
:system
)
read_attribute
(
:system
)
end
end
...
...
app/services/notes/create_service.rb
View file @
27d952b1
...
@@ -11,13 +11,7 @@ module Notes
...
@@ -11,13 +11,7 @@ module Notes
# Skip system notes, like status changes and cross-references.
# Skip system notes, like status changes and cross-references.
unless
note
.
system
unless
note
.
system
event_service
.
leave_note
(
note
,
note
.
author
)
event_service
.
leave_note
(
note
,
note
.
author
)
note
.
create_cross_references!
# Create a cross-reference note if this Note contains GFM that names an
# issue, merge request, or commit.
note
.
references
.
each
do
|
mentioned
|
SystemNoteService
.
cross_reference
(
mentioned
,
note
.
noteable
,
note
.
author
)
end
execute_hooks
(
note
)
execute_hooks
(
note
)
end
end
end
end
...
...
app/services/notes/update_service.rb
View file @
27d952b1
...
@@ -4,7 +4,7 @@ module Notes
...
@@ -4,7 +4,7 @@ module Notes
return
note
unless
note
.
editable?
return
note
unless
note
.
editable?
note
.
update_attributes
(
params
.
merge
(
updated_by:
current_user
))
note
.
update_attributes
(
params
.
merge
(
updated_by:
current_user
))
note
.
create_new_cross_references!
note
.
reset_events_cache
note
.
reset_events_cache
note
note
...
...
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