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
e33ddfeb
Commit
e33ddfeb
authored
Apr 03, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ClosingIssueExtractor.
parent
b492f0f8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
app/models/commit.rb
app/models/commit.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
lib/gitlab/closing_issue_extractor.rb
lib/gitlab/closing_issue_extractor.rb
+11
-12
No files found.
app/models/commit.rb
View file @
e33ddfeb
...
...
@@ -118,7 +118,7 @@ class Commit
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
def
closes_issues
(
project
,
current_user
=
self
.
committer
)
Gitlab
::
ClosingIssueExtractor
.
closed_by_message_in_project
(
safe_message
,
project
,
current_user
)
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
closed_by_message
(
safe_message
)
end
# Mentionable override.
...
...
app/models/merge_request.rb
View file @
e33ddfeb
...
...
@@ -260,8 +260,8 @@ class MergeRequest < ActiveRecord::Base
def
closes_issues
(
current_user
=
self
.
author
)
if
target_branch
==
project
.
default_branch
issues
=
commits
.
flat_map
{
|
c
|
c
.
closes_issues
(
project
,
current_user
)
}
issues
.
push
(
*
Gitlab
::
ClosingIssueExtractor
.
closed_by_message
_in_project
(
description
,
project
,
current_user
))
issues
.
push
(
*
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
closed_by_message
(
description
))
issues
.
uniq
.
sort_by
(
&
:id
)
else
[]
...
...
lib/gitlab/closing_issue_extractor.rb
View file @
e33ddfeb
module
Gitlab
module
ClosingIssueExtractor
class
ClosingIssueExtractor
ISSUE_CLOSING_REGEX
=
Regexp
.
new
(
Gitlab
.
config
.
gitlab
.
issue_closing_pattern
)
def
self
.
closed_by_message_in_project
(
message
,
project
,
current_user
=
nil
)
issues
=
[]
def
initialize
(
project
,
current_user
=
nil
)
@extractor
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
end
unless
message
.
nil?
md
=
message
.
scan
(
ISSUE_CLOSING_REGEX
)
def
closed_by_message
(
message
)
return
[]
if
message
.
nil?
md
.
each
do
|
ref
|
extractor
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
extractor
.
analyze
(
ref
[
0
])
issues
+=
extractor
.
issues
end
end
closing_statements
=
message
.
scan
(
ISSUE_CLOSING_REGEX
).
map
{
|
ref
|
ref
[
0
]
}.
join
(
" "
)
@extractor
.
analyze
(
closing_statements
)
issues
.
uniq
@extractor
.
issues
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