BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
044e0e33
Commit
044e0e33
authored
Dec 02, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow invalid URLs in closing pattern
parent
60828ab4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletion
+52
-1
closing_issue_extractor.rb
lib/gitlab/closing_issue_extractor.rb
+3
-1
closing_issue_extractor_spec.rb
spec/lib/gitlab/closing_issue_extractor_spec.rb
+49
-0
No files found.
lib/gitlab/closing_issue_extractor.rb
View file @
044e0e33
module
Gitlab
class
ClosingIssueExtractor
ISSUE_CLOSING_REGEX
=
begin
link_pattern
=
URI
.
regexp
(
%w(http https)
)
pattern
=
Gitlab
.
config
.
gitlab
.
issue_closing_pattern
pattern
=
pattern
.
sub
(
'%{issue_ref}'
,
"(?:(?:
#{
Issue
.
link_reference
_pattern
}
)|(?:
#{
Issue
.
reference_pattern
}
))"
)
pattern
=
pattern
.
sub
(
'%{issue_ref}'
,
"(?:(?:
#{
link
_pattern
}
)|(?:
#{
Issue
.
reference_pattern
}
))"
)
Regexp
.
new
(
pattern
).
freeze
end
...
...
spec/lib/gitlab/closing_issue_extractor_spec.rb
View file @
044e0e33
...
...
@@ -2,11 +2,18 @@ require 'spec_helper'
describe
Gitlab
::
ClosingIssueExtractor
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue2
)
{
create
(
:issue
,
project:
project2
)
}
let
(
:reference
)
{
issue
.
to_reference
}
let
(
:cross_reference
)
{
issue2
.
to_reference
(
project
)
}
subject
{
described_class
.
new
(
project
,
project
.
creator
)
}
before
do
project2
.
team
<<
[
project
.
creator
,
:master
]
end
describe
"#closed_by_message"
do
context
'with a single reference'
do
it
do
...
...
@@ -130,6 +137,27 @@ describe Gitlab::ClosingIssueExtractor do
end
end
context
"with a cross-project reference"
do
it
do
message
=
"Closes
#{
cross_reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue2
])
end
end
context
"with a cross-project URL"
do
it
do
message
=
"Closes
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project2
.
to_reference
}
/issues/
#{
issue2
.
iid
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([
issue2
])
end
end
context
"with an invalid URL"
do
it
do
message
=
"Closes https://google.com/
#{
project2
.
to_reference
}
/issues/
#{
issue2
.
iid
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
eq
([])
end
end
context
'with multiple references'
do
let
(
:other_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:third_issue
)
{
create
(
:issue
,
project:
project
)
}
...
...
@@ -171,6 +199,27 @@ describe Gitlab::ClosingIssueExtractor do
expect
(
subject
.
closed_by_message
(
message
)).
to
match_array
([
issue
,
other_issue
,
third_issue
])
end
it
"fetches cross-project references"
do
message
=
"Closes
#{
reference
}
and
#{
cross_reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
match_array
([
issue
,
issue2
])
end
it
"fetches cross-project URL references"
do
message
=
"Closes
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project2
.
to_reference
}
/issues/
#{
issue2
.
iid
}
and
#{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
match_array
([
issue
,
issue2
])
end
it
"ignores invalid cross-project URL references"
do
message
=
"Closes https://google.com/
#{
project2
.
to_reference
}
/issues/
#{
issue2
.
iid
}
and
#{
reference
}
"
expect
(
subject
.
closed_by_message
(
message
)).
to
match_array
([
issue
])
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