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
Léo-Paul Géneau
gitlab-ce
Commits
2207e5a6
Commit
2207e5a6
authored
Apr 23, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up ReferenceExtractor
parent
c0a97d70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
lib/gitlab/reference_extractor.rb
lib/gitlab/reference_extractor.rb
+11
-9
No files found.
lib/gitlab/reference_extractor.rb
View file @
2207e5a6
...
@@ -14,39 +14,39 @@ module Gitlab
...
@@ -14,39 +14,39 @@ module Gitlab
def
users
def
users
result
=
pipeline_result
(
:user
)
result
=
pipeline_result
(
:user
)
result
[
:references
][
:user
].
flatten
.
compact
.
uniq
result
.
uniq
end
end
def
labels
def
labels
result
=
pipeline_result
(
:label
)
result
=
pipeline_result
(
:label
)
result
[
:references
][
:label
].
compact
.
uniq
result
.
uniq
end
end
def
issues
def
issues
# TODO (rspeicher): What about external issues?
# TODO (rspeicher): What about external issues?
result
=
pipeline_result
(
:issue
)
result
=
pipeline_result
(
:issue
)
result
[
:references
][
:issue
].
compact
.
uniq
result
.
uniq
end
end
def
merge_requests
def
merge_requests
result
=
pipeline_result
(
:merge_request
)
result
=
pipeline_result
(
:merge_request
)
result
[
:references
][
:merge_request
].
compact
.
uniq
result
.
uniq
end
end
def
snippets
def
snippets
result
=
pipeline_result
(
:snippet
)
result
=
pipeline_result
(
:snippet
)
result
[
:references
][
:snippet
].
compact
.
uniq
result
.
uniq
end
end
def
commits
def
commits
result
=
pipeline_result
(
:commit
)
result
=
pipeline_result
(
:commit
)
result
[
:references
][
:commit
].
compact
.
uniq
result
.
uniq
end
end
def
commit_ranges
def
commit_ranges
result
=
pipeline_result
(
:commit_range
)
result
=
pipeline_result
(
:commit_range
)
result
[
:references
][
:commit_range
].
compact
.
uniq
result
.
uniq
end
end
private
private
...
@@ -56,7 +56,7 @@ module Gitlab
...
@@ -56,7 +56,7 @@ module Gitlab
#
#
# filter_type - Symbol reference type (e.g., :commit, :issue, etc.)
# filter_type - Symbol reference type (e.g., :commit, :issue, etc.)
#
#
# Returns the results
Hash
# Returns the results
Array for the requested filter type
def
pipeline_result
(
filter_type
)
def
pipeline_result
(
filter_type
)
klass
=
filter_type
.
to_s
.
camelize
+
'ReferenceFilter'
klass
=
filter_type
.
to_s
.
camelize
+
'ReferenceFilter'
filter
=
"Gitlab::Markdown::
#{
klass
}
"
.
constantize
filter
=
"Gitlab::Markdown::
#{
klass
}
"
.
constantize
...
@@ -69,7 +69,9 @@ module Gitlab
...
@@ -69,7 +69,9 @@ module Gitlab
}
}
pipeline
=
HTML
::
Pipeline
.
new
([
filter
],
context
)
pipeline
=
HTML
::
Pipeline
.
new
([
filter
],
context
)
pipeline
.
call
(
@_text
)
result
=
pipeline
.
call
(
@_text
)
result
[
:references
][
filter_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