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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f8b0836c
Commit
f8b0836c
authored
Oct 17, 2020
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indicate reverted status of a merge request on it's individual page
parent
0795a0fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
app/models/commit.rb
app/models/commit.rb
+5
-1
app/models/merge_request.rb
app/models/merge_request.rb
+22
-0
app/views/projects/merge_requests/_mr_title.html.haml
app/views/projects/merge_requests/_mr_title.html.haml
+7
-2
No files found.
app/models/commit.rb
View file @
f8b0836c
...
...
@@ -428,6 +428,10 @@ class Commit
end
def
has_been_reverted?
(
current_user
,
notes_association
=
nil
)
!!
reverting_commit
(
current_user
,
notes_association
)
end
def
reverting_commit
(
current_user
,
notes_association
=
nil
)
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
project
,
current_user
)
notes_association
||=
notes_with_associations
...
...
@@ -435,7 +439,7 @@ class Commit
note
.
all_references
(
current_user
,
extractor:
ext
)
end
ext
.
commits
.
any?
{
|
commit_ref
|
commit_ref
.
reverts_commit?
(
self
,
current_user
)
}
ext
.
commits
.
find
{
|
commit_ref
|
commit_ref
.
reverts_commit?
(
self
,
current_user
)
}
end
def
change_type_title
(
user
)
...
...
app/models/merge_request.rb
View file @
f8b0836c
...
...
@@ -1576,6 +1576,28 @@ class MergeRequest < ApplicationRecord
!
merge_commit
.
has_been_reverted?
(
current_user
,
notes_association
)
end
def
is_reverted?
(
current_user
)
!!
reverting_merge_request
(
current_user
)
end
def
reverting_merge_request
(
current_user
)
return
nil
unless
merge_commit
return
nil
unless
merged_at
cutoff
=
merged_at
-
1
.
minute
notes_association
=
notes_with_associations
.
where
(
'created_at >= ?'
,
cutoff
)
reverting_commit
=
merge_commit
.
reverting_commit
(
current_user
,
notes_association
)
MergeRequestsFinder
.
new
(
current_user
,
project_id:
project
.
id
,
commit_sha:
reverting_commit
.
sha
,
state:
'merged'
).
execute
.
first
if
reverting_commit
end
def
merged_at
strong_memoize
(
:merged_at
)
do
next
unless
merged?
...
...
app/views/projects/merge_requests/_mr_title.html.haml
View file @
f8b0836c
...
...
@@ -14,8 +14,13 @@
.detail-page-header-body
.issuable-status-box.status-box
{
class:
status_box_class
(
@merge_request
)
}
=
sprite_icon
(
state_icon_name
,
css_class:
'd-block d-sm-none'
)
%span
.d-none.d-sm-block
=
state_human_name
-
if
@merge_request
.
is_reverted?
(
current_user
)
%span
.d-none.d-sm-block
=
_
(
"Merged"
)
=
link_to
'(reverted)'
,
merge_request_path
(
@merge_request
.
reverting_merge_request
(
current_user
))
-
else
%span
.d-none.d-sm-block
=
state_human_name
.issuable-meta
#js-issuable-header-warnings
...
...
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