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
Jérome Perrin
gitlab-ce
Commits
f5c89b21
Commit
f5c89b21
authored
Nov 06, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mentioned_inside_mr' into 'master'
Do not mention MR if commit is a part of MR See merge request !1242
parents
08c04bc9
150fc0cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
app/models/note.rb
app/models/note.rb
+10
-1
spec/models/note_spec.rb
spec/models/note_spec.rb
+6
-0
No files found.
app/models/note.rb
View file @
f5c89b21
...
...
@@ -90,7 +90,7 @@ class Note < ActiveRecord::Base
note_options
.
merge!
(
noteable:
noteable
)
end
create
(
note_options
)
create
(
note_options
)
unless
cross_reference_disallowed?
(
noteable
,
mentioner
)
end
def
create_milestone_change_note
(
noteable
,
project
,
author
,
milestone
)
...
...
@@ -165,6 +165,15 @@ class Note < ActiveRecord::Base
[
:discussion
,
type
.
try
(
:underscore
),
id
,
line_code
].
join
(
"-"
).
to_sym
end
# Determine if cross reference note should be created.
# eg. mentioning a commit in MR comments which exists inside a MR
# should not create "mentioned in" note.
def
cross_reference_disallowed?
(
noteable
,
mentioner
)
if
mentioner
.
kind_of?
(
MergeRequest
)
mentioner
.
commits
.
map
(
&
:id
).
include?
noteable
.
id
end
end
# Determine whether or not a cross-reference note already exists.
def
cross_reference_exists?
(
noteable
,
mentioner
)
gfm_reference
=
mentioner_gfm_ref
(
noteable
,
mentioner
)
...
...
spec/models/note_spec.rb
View file @
f5c89b21
...
...
@@ -249,6 +249,12 @@ describe Note do
its
(
:note
)
{
should
==
"_mentioned in merge request !
#{
mergereq
.
iid
}
_"
}
end
context
'commit contained in a merge request'
do
subject
{
Note
.
create_cross_reference_note
(
mergereq
.
commits
.
first
,
mergereq
,
author
,
project
)
}
it
{
should
be_nil
}
end
context
'commit from issue'
do
subject
{
Note
.
create_cross_reference_note
(
commit
,
issue
,
author
,
project
)
}
...
...
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