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
38fb6279
Commit
38fb6279
authored
Apr 20, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify `cross_project_reference` with `to_reference`
parent
ca268b85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+17
-7
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
38fb6279
...
@@ -135,15 +135,25 @@ module GitlabMarkdownHelper
...
@@ -135,15 +135,25 @@ module GitlabMarkdownHelper
end
end
end
end
# Returns the text necessary to reference `entity` across projects
#
# project - Project to reference
# entity - Object that responds to `to_reference`
#
# Examples:
#
# cross_project_reference(project, project.issues.first)
# # => 'namespace1/project1#123'
#
# cross_project_reference(project, project.merge_requests.first)
# # => 'namespace1/project1!345'
#
# Returns a String
def
cross_project_reference
(
project
,
entity
)
def
cross_project_reference
(
project
,
entity
)
path
=
project
.
path_with_namespace
if
entity
.
respond_to?
(
:to_reference
)
"
#{
project
.
to_reference
}#{
entity
.
to_reference
}
"
if
entity
.
kind_of?
(
Issue
)
[
path
,
entity
.
iid
].
join
(
'#'
)
elsif
entity
.
kind_of?
(
MergeRequest
)
[
path
,
entity
.
iid
].
join
(
'!'
)
else
else
raise
'Not supported type
'
'
'
end
end
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