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
Tatuya Kamada
gitlab-ce
Commits
9f9f0c35
Commit
9f9f0c35
authored
Oct 12, 2015
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show merge requests which close current issue
parent
bd3689e9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
40 additions
and
2 deletions
+40
-2
CHANGELOG
CHANGELOG
+1
-0
app/assets/stylesheets/pages/issues.scss
app/assets/stylesheets/pages/issues.scss
+5
-0
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+7
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+4
-0
app/models/issue.rb
app/models/issue.rb
+10
-0
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/views/projects/issues/_closed_by_box.html.haml
app/views/projects/issues/_closed_by_box.html.haml
+6
-0
app/views/projects/issues/show.html.haml
app/views/projects/issues/show.html.haml
+2
-1
No files found.
CHANGELOG
View file @
9f9f0c35
...
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased)
v 8.1.0 (unreleased)
- Fix error preventing displaying of commit data for a directory with a leading dot (Stan Hu)
- Fix error preventing displaying of commit data for a directory with a leading dot (Stan Hu)
- Speed up load times of issue detail pages by roughly 1.5x
- Speed up load times of issue detail pages by roughly 1.5x
- If a merge request is to close an issue, show this on the issue page (Zeger-Jan van de Weg)
- Make diff file view easier to use on mobile screens (Stan Hu)
- Make diff file view easier to use on mobile screens (Stan Hu)
- Improved performance of finding users by username or Email address
- Improved performance of finding users by username or Email address
- Fix bug where merge request comments created by API would not trigger notifications (Stan Hu)
- Fix bug where merge request comments created by API would not trigger notifications (Stan Hu)
...
...
app/assets/stylesheets/pages/issues.scss
View file @
9f9f0c35
...
@@ -132,6 +132,11 @@ form.edit-issue {
...
@@ -132,6 +132,11 @@ form.edit-issue {
}
}
}
}
.issue-closed-by-widget
{
padding
:
16px
0
;
margin
:
0px
;
}
.issue-form
.select2-container
{
.issue-form
.select2-container
{
width
:
250px
!
important
;
width
:
250px
!
important
;
}
}
app/controllers/projects/issues_controller.rb
View file @
9f9f0c35
...
@@ -14,6 +14,9 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -14,6 +14,9 @@ class Projects::IssuesController < Projects::ApplicationController
# Allow issues bulk update
# Allow issues bulk update
before_action
:authorize_admin_issues!
,
only:
[
:bulk_update
]
before_action
:authorize_admin_issues!
,
only:
[
:bulk_update
]
# Cross-reference merge requests
before_action
:closed_by_merge_requests
,
only:
[
:show
]
respond_to
:html
respond_to
:html
def
index
def
index
...
@@ -112,6 +115,10 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -112,6 +115,10 @@ class Projects::IssuesController < Projects::ApplicationController
render
nothing:
true
render
nothing:
true
end
end
def
closed_by_merge_requests
@closed_by_mr
=
@issue
.
closed_by_merge_requests
(
current_user
)
end
protected
protected
def
issue
def
issue
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
9f9f0c35
...
@@ -259,7 +259,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -259,7 +259,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@commits
=
@merge_request
.
commits
@commits
=
@merge_request
.
commits
@merge_request_diff
=
@merge_request
.
merge_request_diff
@merge_request_diff
=
@merge_request
.
merge_request_diff
if
@merge_request
.
locked_long_ago?
if
@merge_request
.
locked_long_ago?
@merge_request
.
unlock_mr
@merge_request
.
unlock_mr
@merge_request
.
close
@merge_request
.
close
...
...
app/helpers/issues_helper.rb
View file @
9f9f0c35
...
@@ -83,6 +83,10 @@ module IssuesHelper
...
@@ -83,6 +83,10 @@ module IssuesHelper
end
end
end
end
def
merge_requests_sentence
(
merge_requests
)
merge_requests
.
map
(
&
:to_reference
).
to_sentence
end
# Required for Gitlab::Markdown::IssueReferenceFilter
# Required for Gitlab::Markdown::IssueReferenceFilter
module_function
:url_for_issue
module_function
:url_for_issue
end
end
app/models/issue.rb
View file @
9f9f0c35
...
@@ -95,4 +95,14 @@ class Issue < ActiveRecord::Base
...
@@ -95,4 +95,14 @@ class Issue < ActiveRecord::Base
def
source_project
def
source_project
project
project
end
end
# From all notes on this issue, we'll select the system notes about linked
# merge requests. Of those, the MRs closing `self` are returned.
def
closed_by_merge_requests
(
current_user
)
notes
.
system
.
flat_map
do
|
note
|
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
self
.
project
,
current_user
)
ext
.
analyze
(
note
.
note
)
ext
.
merge_requests
end
.
uniq
.
select
{
|
mr
|
mr
.
closes_issue?
(
self
)
}
end
end
end
app/models/merge_request.rb
View file @
9f9f0c35
...
@@ -294,6 +294,10 @@ class MergeRequest < ActiveRecord::Base
...
@@ -294,6 +294,10 @@ class MergeRequest < ActiveRecord::Base
target_project
target_project
end
end
def
closes_issue?
(
issue
)
closes_issues
.
include?
(
issue
)
end
# Return the set of issues that will be closed if this merge request is accepted.
# Return the set of issues that will be closed if this merge request is accepted.
def
closes_issues
(
current_user
=
self
.
author
)
def
closes_issues
(
current_user
=
self
.
author
)
if
target_branch
==
project
.
default_branch
if
target_branch
==
project
.
default_branch
...
...
app/views/projects/issues/_closed_by_box.html.haml
0 → 100644
View file @
9f9f0c35
.issue-closed-by-widget
%i
.fa.fa-check
-
if
@closed_by_mr
.
count
==
1
This issue will be closed when
#{
gfm
(
@closed_by_mr
.
first
.
to_reference
)
}
is accepted.
-
else
This issue will be closed when any of merge requests
#{
gfm
(
merge_requests_sentence
(
@closed_by_mr
.
sort
))
}
is accepted.
app/views/projects/issues/show.html.haml
View file @
9f9f0c35
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
=
markdown
(
@issue
.
description
)
=
markdown
(
@issue
.
description
)
%textarea
.hidden.js-task-list-field
%textarea
.hidden.js-task-list-field
=
@issue
.
description
=
@issue
.
description
-
if
@closed_by_mr
.
present?
=
render
'projects/issues/closed_by_box'
.issue-discussion
.issue-discussion
=
render
'projects/issues/discussion'
=
render
'projects/issues/discussion'
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