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
6cacd1b2
Commit
6cacd1b2
authored
Nov 16, 2017
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the label system notes from being redacted in the API
parent
3a7bf856
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
1 deletion
+59
-1
app/models/note.rb
app/models/note.rb
+13
-1
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+11
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+4
-0
spec/models/note_spec.rb
spec/models/note_spec.rb
+31
-0
No files found.
app/models/note.rb
View file @
6cacd1b2
...
...
@@ -177,7 +177,13 @@ class Note < ActiveRecord::Base
end
def
cross_reference?
system
?
&&
matches_cross_reference_regex?
return
unless
system
?
if
force_cross_reference_regex_check?
matches_cross_reference_regex?
else
SystemNoteService
.
cross_reference?
(
note
)
end
end
def
diff_note?
...
...
@@ -390,4 +396,10 @@ class Note < ActiveRecord::Base
def
set_discussion_id
self
.
discussion_id
||=
discussion_class
.
discussion_id
(
self
)
end
def
force_cross_reference_regex_check?
return
unless
system
?
SystemNoteMetadata
::
TYPES_WITH_CROSS_REFERENCES
.
include?
(
system_note_metadata
&
.
action
)
end
end
app/models/system_note_metadata.rb
View file @
6cacd1b2
class
SystemNoteMetadata
<
ActiveRecord
::
Base
# These notes's action text might contain a reference that is external.
# We should always force a deep validation upon references that are found
# in this note type.
# Other notes can always be safely shown as all its references are
# in the same project (i.e. with the same permissions)
TYPES_WITH_CROSS_REFERENCES
=
%w[
commit cross_reference
close duplicate
relate unrelate
]
.
freeze
ICON_TYPES
=
%w[
commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved
...
...
app/services/system_note_service.rb
View file @
6cacd1b2
...
...
@@ -637,6 +637,10 @@ module SystemNoteService
create_note
(
NoteSummary
.
new
(
issuable
,
issuable
.
project
,
author
,
body
,
action:
action
))
end
def
cross_reference?
(
note_text
)
note_text
=~
/\A
#{
cross_reference_note_prefix
}
/i
end
private
def
notes_for_mentioner
(
mentioner
,
noteable
,
notes
)
...
...
spec/models/note_spec.rb
View file @
6cacd1b2
...
...
@@ -231,6 +231,37 @@ describe Note do
end
end
describe
'#cross_reference?'
do
it
'falsey for user-generated notes'
do
note
=
create
(
:note
,
system:
false
)
expect
(
note
.
cross_reference?
).
to
be_falsy
end
context
'when the note might contain cross references'
do
SystemNoteMetadata
::
TYPES_WITH_CROSS_REFERENCES
.
each
do
|
type
|
let
(
:note
)
{
create
(
:note
,
:system
)
}
let!
(
:metadata
)
{
create
(
:system_note_metadata
,
note:
note
,
action:
type
)
}
it
'delegates to the cross-reference regex'
do
expect
(
note
).
to
receive
(
:matches_cross_reference_regex?
).
and_return
(
false
)
note
.
cross_reference?
end
end
end
context
'when the note cannot contain cross references'
do
let
(
:commit_note
)
{
build
(
:note
,
note:
'mentioned in 1312312313 something else.'
,
system:
true
)
}
let
(
:label_note
)
{
build
(
:note
,
note:
'added ~2323232323'
,
system:
true
)
}
it
'scan for a `mentioned in` prefix'
do
expect
(
commit_note
.
cross_reference?
).
to
be_truthy
expect
(
label_note
.
cross_reference?
).
to
be_falsy
end
end
end
describe
'clear_blank_line_code!'
do
it
'clears a blank line code before validation'
do
note
=
build
(
:note
,
line_code:
' '
)
...
...
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