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
d34733ef
Commit
d34733ef
authored
Feb 14, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show revert button if commit/MR has already been reverted.
parent
e8d15f13
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
10 deletions
+35
-10
app/models/commit.rb
app/models/commit.rb
+20
-6
app/models/merge_request.rb
app/models/merge_request.rb
+10
-0
app/views/projects/commit/_commit_box.html.haml
app/views/projects/commit/_commit_box.html.haml
+2
-1
app/views/projects/merge_requests/_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+2
-2
app/views/projects/merge_requests/widget/_merged.html.haml
app/views/projects/merge_requests/widget/_merged.html.haml
+1
-1
No files found.
app/models/commit.rb
View file @
d34733ef
...
@@ -219,14 +219,20 @@ class Commit
...
@@ -219,14 +219,20 @@ class Commit
"revert-
#{
short_id
}
"
"revert-
#{
short_id
}
"
end
end
def
revert_description
if
merged_merge_request
"This reverts merge request
#{
merged_merge_request
.
to_reference
}
"
else
"This reverts commit
#{
sha
}
"
end
end
def
revert_message
def
revert_message
description
=
if
merged_merge_request
"Revert
\"
#{
title
}
\"
"
+
"
\n\n
#{
revert_description
}
"
"This reverts merge request
#{
merged_merge_request
.
to_reference
}
"
end
else
"This reverts commit
#{
sha
}
"
end
"Revert
\"
#{
title
}
\"
"
+
"
\n\n
#{
description
}
"
def
reverts_commit?
(
commit
)
description
.
include?
(
commit
.
revert_description
)
end
end
def
merge_commit?
def
merge_commit?
...
@@ -239,6 +245,14 @@ class Commit
...
@@ -239,6 +245,14 @@ class Commit
@merged_merge_request
=
merge_commit?
&&
MergeRequest
.
find_by
(
merge_commit_sha:
id
)
@merged_merge_request
=
merge_commit?
&&
MergeRequest
.
find_by
(
merge_commit_sha:
id
)
end
end
def
has_been_reverted?
(
current_user
=
nil
,
noteable
=
self
)
Gitlab
::
ReferenceExtractor
.
lazily
do
[
self
,
*
noteable
.
notes
].
flat_map
do
|
note
|
note
.
all_references
(
current_user
).
commits
end
end
.
any?
{
|
commit_ref
|
commit_ref
.
reverts_commit?
(
self
)
}
end
private
private
def
repo_changes
def
repo_changes
...
...
app/models/merge_request.rb
View file @
d34733ef
...
@@ -533,4 +533,14 @@ class MergeRequest < ActiveRecord::Base
...
@@ -533,4 +533,14 @@ class MergeRequest < ActiveRecord::Base
[
diff_base_commit
,
last_commit
]
[
diff_base_commit
,
last_commit
]
end
end
def
merge_commit
@merge_commit
||=
project
.
commit
(
merge_commit_sha
)
if
merge_commit_sha
end
def
has_been_reverted?
(
current_user
=
nil
)
if
merge_commit
merge_commit
.
has_been_reverted?
(
current_user
,
self
)
end
end
end
end
app/views/projects/commit/_commit_box.html.haml
View file @
d34733ef
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
=
link_to
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@commit
),
class:
"btn btn-grouped"
do
=
link_to
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@commit
),
class:
"btn btn-grouped"
do
=
icon
(
'files-o'
)
=
icon
(
'files-o'
)
Browse Files
Browse Files
=
revert_commit_link
(
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
@commit
.
id
))
-
unless
@commit
.
has_been_reverted?
(
current_user
)
=
revert_commit_link
(
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
@commit
.
id
))
%div
%div
%p
%p
...
...
app/views/projects/merge_requests/_show.html.haml
View file @
d34733ef
...
@@ -85,8 +85,8 @@
...
@@ -85,8 +85,8 @@
=
spinner
=
spinner
=
render
'shared/issuable/sidebar'
,
issuable:
@merge_request
=
render
'shared/issuable/sidebar'
,
issuable:
@merge_request
-
if
@merge_request
.
merge_commit
_sha
-
if
@merge_request
.
merge_commit
&&
!
@merge_request
.
has_been_reverted?
(
current_user
)
=
render
"projects/commit/revert"
,
commit_id:
@merge_request
.
merge_commit
_sha
,
title:
@merge_request
.
title
=
render
"projects/commit/revert"
,
commit_id:
@merge_request
.
merge_commit
.
id
,
title:
@merge_request
.
title
:javascript
:javascript
var
merge_request
;
var
merge_request
;
...
...
app/views/projects/merge_requests/widget/_merged.html.haml
View file @
d34733ef
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
-
if
@merge_request
.
merge_event
-
if
@merge_request
.
merge_event
by
#{
link_to_member
(
@project
,
@merge_request
.
merge_event
.
author
,
avatar:
true
)
}
by
#{
link_to_member
(
@project
,
@merge_request
.
merge_event
.
author
,
avatar:
true
)
}
#{
time_ago_with_tooltip
(
@merge_request
.
merge_event
.
created_at
)
}
#{
time_ago_with_tooltip
(
@merge_request
.
merge_event
.
created_at
)
}
-
if
@merge_request
.
merge_commit_sha
.
present?
-
unless
@merge_request
.
has_been_reverted?
(
current_user
)
=
revert_commit_link
(
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
btn_class:
'sm'
)
=
revert_commit_link
(
namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
btn_class:
'sm'
)
%div
%div
-
if
!
@merge_request
.
source_branch_exists?
||
(
params
[
:delete_source
]
==
'true'
)
-
if
!
@merge_request
.
source_branch_exists?
||
(
params
[
:delete_source
]
==
'true'
)
...
...
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