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
e826c5d0
Commit
e826c5d0
authored
Nov 22, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix link text from group context
parent
6369db01
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
51 additions
and
36 deletions
+51
-36
app/controllers/concerns/preview_markdown.rb
app/controllers/concerns/preview_markdown.rb
+1
-0
app/models/commit.rb
app/models/commit.rb
+6
-6
app/models/commit_range.rb
app/models/commit_range.rb
+4
-4
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+2
-2
app/models/concerns/referable.rb
app/models/concerns/referable.rb
+4
-4
app/models/external_issue.rb
app/models/external_issue.rb
+2
-2
app/models/group.rb
app/models/group.rb
+1
-1
app/models/label.rb
app/models/label.rb
+3
-3
app/models/milestone.rb
app/models/milestone.rb
+3
-3
app/models/project.rb
app/models/project.rb
+3
-3
app/models/snippet.rb
app/models/snippet.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/jk-group-mentions-fix.yml
changelogs/unreleased/jk-group-mentions-fix.yml
+5
-0
lib/banzai/filter/abstract_reference_filter.rb
lib/banzai/filter/abstract_reference_filter.rb
+2
-1
spec/lib/banzai/filter/issue_reference_filter_spec.rb
spec/lib/banzai/filter/issue_reference_filter_spec.rb
+12
-4
No files found.
app/controllers/concerns/preview_markdown.rb
View file @
e826c5d0
...
@@ -8,6 +8,7 @@ module PreviewMarkdown
...
@@ -8,6 +8,7 @@ module PreviewMarkdown
case
controller_name
case
controller_name
when
'wikis'
then
{
pipeline: :wiki
,
project_wiki:
@project_wiki
,
page_slug:
params
[
:id
]
}
when
'wikis'
then
{
pipeline: :wiki
,
project_wiki:
@project_wiki
,
page_slug:
params
[
:id
]
}
when
'snippets'
then
{
skip_project_check:
true
}
when
'snippets'
then
{
skip_project_check:
true
}
when
'groups'
then
{
group:
group
}
else
{}
else
{}
end
end
...
...
app/models/commit.rb
View file @
e826c5d0
...
@@ -109,12 +109,12 @@ class Commit
...
@@ -109,12 +109,12 @@ class Commit
@link_reference_pattern
||=
super
(
"commit"
,
/(?<commit>
#{
COMMIT_SHA_PATTERN
}
)/
)
@link_reference_pattern
||=
super
(
"commit"
,
/(?<commit>
#{
COMMIT_SHA_PATTERN
}
)/
)
end
end
def
to_reference
(
from
_project
=
nil
,
full:
false
)
def
to_reference
(
from
=
nil
,
full:
false
)
commit_reference
(
from
_project
,
id
,
full:
full
)
commit_reference
(
from
,
id
,
full:
full
)
end
end
def
reference_link_text
(
from
_project
=
nil
,
full:
false
)
def
reference_link_text
(
from
=
nil
,
full:
false
)
commit_reference
(
from
_project
,
short_id
,
full:
full
)
commit_reference
(
from
,
short_id
,
full:
full
)
end
end
def
diff_line_count
def
diff_line_count
...
@@ -381,8 +381,8 @@ class Commit
...
@@ -381,8 +381,8 @@ class Commit
private
private
def
commit_reference
(
from
_project
,
referable_commit_id
,
full:
false
)
def
commit_reference
(
from
,
referable_commit_id
,
full:
false
)
reference
=
project
.
to_reference
(
from
_project
,
full:
full
)
reference
=
project
.
to_reference
(
from
,
full:
full
)
if
reference
.
present?
if
reference
.
present?
"
#{
reference
}#{
self
.
class
.
reference_prefix
}#{
referable_commit_id
}
"
"
#{
reference
}#{
self
.
class
.
reference_prefix
}#{
referable_commit_id
}
"
...
...
app/models/commit_range.rb
View file @
e826c5d0
...
@@ -89,8 +89,8 @@ class CommitRange
...
@@ -89,8 +89,8 @@ class CommitRange
alias_method
:id
,
:to_s
alias_method
:id
,
:to_s
def
to_reference
(
from
_project
=
nil
,
full:
false
)
def
to_reference
(
from
=
nil
,
full:
false
)
project_reference
=
project
.
to_reference
(
from
_project
,
full:
full
)
project_reference
=
project
.
to_reference
(
from
,
full:
full
)
if
project_reference
.
present?
if
project_reference
.
present?
project_reference
+
self
.
class
.
reference_prefix
+
self
.
id
project_reference
+
self
.
class
.
reference_prefix
+
self
.
id
...
@@ -99,8 +99,8 @@ class CommitRange
...
@@ -99,8 +99,8 @@ class CommitRange
end
end
end
end
def
reference_link_text
(
from
_project
=
nil
)
def
reference_link_text
(
from
=
nil
)
project_reference
=
project
.
to_reference
(
from
_project
)
project_reference
=
project
.
to_reference
(
from
)
reference
=
ref_from
+
notation
+
ref_to
reference
=
ref_from
+
notation
+
ref_to
if
project_reference
.
present?
if
project_reference
.
present?
...
...
app/models/concerns/mentionable.rb
View file @
e826c5d0
...
@@ -31,11 +31,11 @@ module Mentionable
...
@@ -31,11 +31,11 @@ module Mentionable
#
#
# By default this will be the class name and the result of calling
# By default this will be the class name and the result of calling
# `to_reference` on the object.
# `to_reference` on the object.
def
gfm_reference
(
from
_project
=
nil
)
def
gfm_reference
(
from
=
nil
)
# "MergeRequest" > "merge_request" > "Merge request" > "merge request"
# "MergeRequest" > "merge_request" > "Merge request" > "merge request"
friendly_name
=
self
.
class
.
to_s
.
underscore
.
humanize
.
downcase
friendly_name
=
self
.
class
.
to_s
.
underscore
.
humanize
.
downcase
"
#{
friendly_name
}
#{
to_reference
(
from
_project
)
}
"
"
#{
friendly_name
}
#{
to_reference
(
from
)
}
"
end
end
# The GFM reference to this Mentionable, which shouldn't be included in its #references.
# The GFM reference to this Mentionable, which shouldn't be included in its #references.
...
...
app/models/concerns/referable.rb
View file @
e826c5d0
...
@@ -7,7 +7,7 @@ module Referable
...
@@ -7,7 +7,7 @@ module Referable
# Returns the String necessary to reference this object in Markdown
# Returns the String necessary to reference this object in Markdown
#
#
# from
_project - Refering Projec
t object
# from
- Referring paren
t object
#
#
# This should be overridden by the including class.
# This should be overridden by the including class.
#
#
...
@@ -17,12 +17,12 @@ module Referable
...
@@ -17,12 +17,12 @@ module Referable
# Issue.last.to_reference(other_project) # => "cross-project#1"
# Issue.last.to_reference(other_project) # => "cross-project#1"
#
#
# Returns a String
# Returns a String
def
to_reference
(
_from
_project
=
nil
,
full
:)
def
to_reference
(
_from
=
nil
,
full
:)
''
''
end
end
def
reference_link_text
(
from
_project
=
nil
)
def
reference_link_text
(
from
=
nil
)
to_reference
(
from
_project
)
to_reference
(
from
)
end
end
included
do
included
do
...
...
app/models/external_issue.rb
View file @
e826c5d0
...
@@ -38,11 +38,11 @@ class ExternalIssue
...
@@ -38,11 +38,11 @@ class ExternalIssue
@project
.
id
@project
.
id
end
end
def
to_reference
(
_from
_project
=
nil
,
full:
nil
)
def
to_reference
(
_from
=
nil
,
full:
nil
)
id
id
end
end
def
reference_link_text
(
from
_project
=
nil
)
def
reference_link_text
(
from
=
nil
)
return
"#
#{
id
}
"
if
id
=~
/^\d+$/
return
"#
#{
id
}
"
if
id
=~
/^\d+$/
id
id
...
...
app/models/group.rb
View file @
e826c5d0
...
@@ -97,7 +97,7 @@ class Group < Namespace
...
@@ -97,7 +97,7 @@ class Group < Namespace
end
end
end
end
def
to_reference
(
_from
_project
=
nil
,
full:
nil
)
def
to_reference
(
_from
=
nil
,
full:
nil
)
"
#{
self
.
class
.
reference_prefix
}#{
full_path
}
"
"
#{
self
.
class
.
reference_prefix
}#{
full_path
}
"
end
end
...
...
app/models/label.rb
View file @
e826c5d0
...
@@ -165,12 +165,12 @@ class Label < ActiveRecord::Base
...
@@ -165,12 +165,12 @@ class Label < ActiveRecord::Base
#
#
# Returns a String
# Returns a String
#
#
def
to_reference
(
from
_project
=
nil
,
target_project:
nil
,
format: :id
,
full:
false
)
def
to_reference
(
from
=
nil
,
target_project:
nil
,
format: :id
,
full:
false
)
format_reference
=
label_format_reference
(
format
)
format_reference
=
label_format_reference
(
format
)
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
format_reference
}
"
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
format_reference
}
"
if
from
_project
if
from
"
#{
from
_project
.
to_reference
(
target_project
,
full:
full
)
}#{
reference
}
"
"
#{
from
.
to_reference
(
target_project
,
full:
full
)
}#{
reference
}
"
else
else
reference
reference
end
end
...
...
app/models/milestone.rb
View file @
e826c5d0
...
@@ -162,18 +162,18 @@ class Milestone < ActiveRecord::Base
...
@@ -162,18 +162,18 @@ class Milestone < ActiveRecord::Base
# Milestone.first.to_reference(cross_namespace_project) # => "gitlab-org/gitlab-ce%1"
# Milestone.first.to_reference(cross_namespace_project) # => "gitlab-org/gitlab-ce%1"
# Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1"
# Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1"
#
#
def
to_reference
(
from
_project
=
nil
,
format: :name
,
full:
false
)
def
to_reference
(
from
=
nil
,
format: :name
,
full:
false
)
format_reference
=
milestone_format_reference
(
format
)
format_reference
=
milestone_format_reference
(
format
)
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
format_reference
}
"
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
format_reference
}
"
if
project
if
project
"
#{
project
.
to_reference
(
from
_project
,
full:
full
)
}#{
reference
}
"
"
#{
project
.
to_reference
(
from
,
full:
full
)
}#{
reference
}
"
else
else
reference
reference
end
end
end
end
def
reference_link_text
(
from
_project
=
nil
)
def
reference_link_text
(
from
=
nil
)
self
.
title
self
.
title
end
end
...
...
app/models/project.rb
View file @
e826c5d0
...
@@ -760,10 +760,10 @@ class Project < ActiveRecord::Base
...
@@ -760,10 +760,10 @@ class Project < ActiveRecord::Base
end
end
end
end
def
to_human_reference
(
from
_project
=
nil
)
def
to_human_reference
(
from
=
nil
)
if
cross_namespace_reference?
(
from
_project
)
if
cross_namespace_reference?
(
from
)
name_with_namespace
name_with_namespace
elsif
cross_project_reference?
(
from
_project
)
elsif
cross_project_reference?
(
from
)
name
name
end
end
end
end
...
...
app/models/snippet.rb
View file @
e826c5d0
...
@@ -75,11 +75,11 @@ class Snippet < ActiveRecord::Base
...
@@ -75,11 +75,11 @@ class Snippet < ActiveRecord::Base
@link_reference_pattern
||=
super
(
"snippets"
,
/(?<snippet>\d+)/
)
@link_reference_pattern
||=
super
(
"snippets"
,
/(?<snippet>\d+)/
)
end
end
def
to_reference
(
from
_project
=
nil
,
full:
false
)
def
to_reference
(
from
=
nil
,
full:
false
)
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
id
}
"
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
id
}
"
if
project
.
present?
if
project
.
present?
"
#{
project
.
to_reference
(
from
_project
,
full:
full
)
}#{
reference
}
"
"
#{
project
.
to_reference
(
from
,
full:
full
)
}#{
reference
}
"
else
else
reference
reference
end
end
...
...
app/models/user.rb
View file @
e826c5d0
...
@@ -437,7 +437,7 @@ class User < ActiveRecord::Base
...
@@ -437,7 +437,7 @@ class User < ActiveRecord::Base
username
username
end
end
def
to_reference
(
_from
_project
=
nil
,
target_project:
nil
,
full:
nil
)
def
to_reference
(
_from
=
nil
,
target_project:
nil
,
full:
nil
)
"
#{
self
.
class
.
reference_prefix
}#{
username
}
"
"
#{
self
.
class
.
reference_prefix
}#{
username
}
"
end
end
...
...
changelogs/unreleased/jk-group-mentions-fix.yml
0 → 100644
View file @
e826c5d0
---
title
:
Fix link text from group context
merge_request
:
author
:
type
:
fixed
lib/banzai/filter/abstract_reference_filter.rb
View file @
e826c5d0
...
@@ -213,7 +213,8 @@ module Banzai
...
@@ -213,7 +213,8 @@ module Banzai
end
end
def
object_link_text
(
object
,
matches
)
def
object_link_text
(
object
,
matches
)
text
=
object
.
reference_link_text
(
context
[
:project
])
parent
=
context
[
:project
]
||
context
[
:group
]
text
=
object
.
reference_link_text
(
parent
)
extras
=
object_link_text_extras
(
object
,
matches
)
extras
=
object_link_text_extras
(
object
,
matches
)
text
+=
" (
#{
extras
.
join
(
", "
)
}
)"
if
extras
.
any?
text
+=
" (
#{
extras
.
join
(
", "
)
}
)"
if
extras
.
any?
...
...
spec/lib/banzai/filter/issue_reference_filter_spec.rb
View file @
e826c5d0
...
@@ -343,7 +343,9 @@ describe Banzai::Filter::IssueReferenceFilter do
...
@@ -343,7 +343,9 @@ describe Banzai::Filter::IssueReferenceFilter do
reference
=
"
#{
project
.
full_path
}
#
#{
issue
.
iid
}
"
reference
=
"
#{
project
.
full_path
}
#
#{
issue
.
iid
}
"
doc
=
reference_filter
(
"See
#{
reference
}
"
,
context
)
doc
=
reference_filter
(
"See
#{
reference
}
"
,
context
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
helper
.
url_for_issue
(
issue
.
iid
,
project
)
link
=
doc
.
css
(
'a'
).
first
expect
(
link
.
attr
(
'href'
)).
to
eq
(
helper
.
url_for_issue
(
issue
.
iid
,
project
))
expect
(
link
.
text
).
to
include
(
"
#{
project
.
full_path
}
#
#{
issue
.
iid
}
"
)
end
end
it
'ignores reference for shorthand cross-reference'
do
it
'ignores reference for shorthand cross-reference'
do
...
@@ -358,7 +360,9 @@ describe Banzai::Filter::IssueReferenceFilter do
...
@@ -358,7 +360,9 @@ describe Banzai::Filter::IssueReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference
}
"
,
context
)
doc
=
reference_filter
(
"See
#{
reference
}
"
,
context
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
(
helper
.
url_for_issue
(
issue
.
iid
,
project
)
+
"#note_123"
)
link
=
doc
.
css
(
'a'
).
first
expect
(
link
.
attr
(
'href'
)).
to
eq
(
helper
.
url_for_issue
(
issue
.
iid
,
project
)
+
"#note_123"
)
expect
(
link
.
text
).
to
include
(
"
#{
project
.
full_path
}
#
#{
issue
.
iid
}
"
)
end
end
it
'links to a valid reference for cross-reference in link href'
do
it
'links to a valid reference for cross-reference in link href'
do
...
@@ -367,7 +371,9 @@ describe Banzai::Filter::IssueReferenceFilter do
...
@@ -367,7 +371,9 @@ describe Banzai::Filter::IssueReferenceFilter do
doc
=
reference_filter
(
"See
#{
reference_link
}
"
,
context
)
doc
=
reference_filter
(
"See
#{
reference_link
}
"
,
context
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
helper
.
url_for_issue
(
issue
.
iid
,
project
)
+
"#note_123"
link
=
doc
.
css
(
'a'
).
first
expect
(
link
.
attr
(
'href'
)).
to
eq
(
helper
.
url_for_issue
(
issue
.
iid
,
project
)
+
"#note_123"
)
expect
(
link
.
text
).
to
include
(
'Reference'
)
end
end
it
'links to a valid reference for issue reference in the link href'
do
it
'links to a valid reference for issue reference in the link href'
do
...
@@ -375,7 +381,9 @@ describe Banzai::Filter::IssueReferenceFilter do
...
@@ -375,7 +381,9 @@ describe Banzai::Filter::IssueReferenceFilter do
reference_link
=
%{<a href="#{reference}">Reference</a>}
reference_link
=
%{<a href="#{reference}">Reference</a>}
doc
=
reference_filter
(
"See
#{
reference_link
}
"
,
context
)
doc
=
reference_filter
(
"See
#{
reference_link
}
"
,
context
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
helper
.
url_for_issue
(
issue
.
iid
,
project
)
link
=
doc
.
css
(
'a'
).
first
expect
(
link
.
attr
(
'href'
)).
to
eq
(
helper
.
url_for_issue
(
issue
.
iid
,
project
))
expect
(
link
.
text
).
to
include
(
'Reference'
)
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