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
Boxiang Sun
gitlab-ce
Commits
71b2cc1d
Commit
71b2cc1d
authored
Nov 16, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverting to the simpler approach
parent
160324d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
25 deletions
+28
-25
app/models/commit.rb
app/models/commit.rb
+1
-1
app/models/note.rb
app/models/note.rb
+13
-1
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+10
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+4
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+0
-23
No files found.
app/models/commit.rb
View file @
71b2cc1d
...
...
@@ -26,7 +26,7 @@ class Commit
DIFF_HARD_LIMIT_LINES
=
50000
MIN_SHA_LENGTH
=
7
COMMIT_SHA_PATTERN
=
/
(?<!\s[~#!@:])
\h{
#{
MIN_SHA_LENGTH
}
,40}/
.
freeze
COMMIT_SHA_PATTERN
=
/\h{
#{
MIN_SHA_LENGTH
}
,40}/
.
freeze
def
banzai_render_context
(
field
)
context
=
{
pipeline: :single_line
,
project:
self
.
project
}
...
...
app/models/note.rb
View file @
71b2cc1d
...
...
@@ -169,7 +169,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?
...
...
@@ -382,4 +388,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 @
71b2cc1d
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[
cross_reference
milestone
]
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 @
71b2cc1d
...
...
@@ -583,6 +583,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/commit_spec.rb
View file @
71b2cc1d
...
...
@@ -468,27 +468,4 @@ eos
expect
(
described_class
.
valid_hash?
(
'a'
*
41
)).
to
be
false
end
end
describe
'.reference_pattern'
do
where
(
:ref
,
:matches?
)
do
sha
=
Digest
::
SHA1
.
hexdigest
'thisisacommitid'
[
[
sha
.
first
(
Commit
::
MIN_SHA_LENGTH
-
1
),
false
],
[
sha
.
first
(
Commit
::
MIN_SHA_LENGTH
),
true
],
[
sha
,
true
],
[
'~'
<<
sha
,
false
],
# labels
[
'!'
<<
sha
,
false
],
# merge_request
[
':'
<<
sha
,
false
],
# emoji
[
'#'
<<
sha
,
false
],
# issue
[
'@'
<<
sha
,
false
],
# user
]
end
with_them
do
it
"should match only on commit references"
do
expect
(
Commit
.
reference_pattern
.
match
(
ref
).
present?
).
to
eq
(
matches?
)
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