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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
83d552d5
Commit
83d552d5
authored
Mar 03, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable reference creation for comments surrounded by code/preformatted blocks
parent
6c1074e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/reference_extractor.rb
lib/gitlab/reference_extractor.rb
+7
-1
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+20
-0
No files found.
CHANGELOG
View file @
83d552d5
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 7.10.0 (unreleased)
v 7.10.0 (unreleased)
- Disable reference creation for comments surrounded by code/preformatted blocks (Stan Hu)
- enable line wrapping per default and remove the checkbox to toggle it (Hannes Rosenögger)
- enable line wrapping per default and remove the checkbox to toggle it (Hannes Rosenögger)
- extend the commit calendar to show the actual commits made on a date (Hannes Rosenögger)
- extend the commit calendar to show the actual commits made on a date (Hannes Rosenögger)
- Add a service to support external wikis (Hannes Rosenögger)
- Add a service to support external wikis (Hannes Rosenögger)
...
...
lib/gitlab/reference_extractor.rb
View file @
83d552d5
...
@@ -11,7 +11,13 @@ module Gitlab
...
@@ -11,7 +11,13 @@ module Gitlab
end
end
def
analyze
(
string
,
project
)
def
analyze
(
string
,
project
)
parse_references
(
string
.
dup
,
project
)
text
=
string
.
dup
# Remove preformatted/code blocks so that references are not included
text
.
gsub!
(
%r{<pre>.*?</pre>|<code>.*?</code>}m
)
{
|
match
|
''
}
text
.
gsub!
(
%r{^```.*?^```}m
)
{
|
match
|
''
}
parse_references
(
text
,
project
)
end
end
# Given a valid project, resolve the extracted identifiers of the requested type to
# Given a valid project, resolve the extracted identifiers of the requested type to
...
...
spec/lib/gitlab/reference_extractor_spec.rb
View file @
83d552d5
...
@@ -50,6 +50,26 @@ describe Gitlab::ReferenceExtractor do
...
@@ -50,6 +50,26 @@ describe Gitlab::ReferenceExtractor do
expect
(
text
).
to
eq
(
'issue #123 is just the worst, @user'
)
expect
(
text
).
to
eq
(
'issue #123 is just the worst, @user'
)
end
end
it
'extracts no references for <pre>..</pre> blocks'
do
subject
.
analyze
(
"<pre>def puts '#1 issue'
\n
end
\n
</pre>```"
,
nil
)
expect
(
subject
.
issues
).
to
be_blank
end
it
'extracts no references for <code>..</code> blocks'
do
subject
.
analyze
(
"<code>def puts '!1 request'
\n
end
\n
</code>```"
,
nil
)
expect
(
subject
.
merge_requests
).
to
be_blank
end
it
'extracts no references for code blocks with language'
do
subject
.
analyze
(
"this code:
\n
```ruby
\n
def puts '#1 issue'
\n
end
\n
```"
,
nil
)
expect
(
subject
.
issues
).
to
be_blank
end
it
'extracts issue references for invalid code blocks'
do
subject
.
analyze
(
'test: ```this one talks about issue #1234```'
,
nil
)
expect
(
subject
.
issues
).
to
eq
([{
project:
nil
,
id:
'1234'
}])
end
it
'handles all possible kinds of references'
do
it
'handles all possible kinds of references'
do
accessors
=
Gitlab
::
Markdown
::
TYPES
.
map
{
|
t
|
"
#{
t
}
s"
.
to_sym
}
accessors
=
Gitlab
::
Markdown
::
TYPES
.
map
{
|
t
|
"
#{
t
}
s"
.
to_sym
}
expect
(
subject
).
to
respond_to
(
*
accessors
)
expect
(
subject
).
to
respond_to
(
*
accessors
)
...
...
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