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
34e26b82
Commit
34e26b82
authored
Feb 03, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add button to revert commit on Commit detail page.
parent
006089f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
2 deletions
+27
-2
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+7
-0
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+7
-0
app/views/projects/commit/_commit_box.html.haml
app/views/projects/commit/_commit_box.html.haml
+11
-2
app/views/projects/commit/show.html.haml
app/views/projects/commit/show.html.haml
+2
-0
No files found.
app/controllers/projects/commit_controller.rb
View file @
34e26b82
...
...
@@ -2,6 +2,8 @@
#
# Not to be confused with CommitsController, plural.
class
Projects::CommitController
<
Projects
::
ApplicationController
include
CreatesCommit
# Authorize
before_action
:require_non_empty_project
before_action
:authorize_download_code!
,
except:
[
:cancel_builds
,
:retry_builds
]
...
...
@@ -9,6 +11,7 @@ class Projects::CommitController < Projects::ApplicationController
before_action
:authorize_read_commit_status!
,
only:
[
:builds
]
before_action
:commit
before_action
:define_show_vars
,
only:
[
:show
,
:builds
]
before_action
:authorize_edit_tree!
,
only:
[
:revert
]
def
show
apply_diff_view_cookie!
...
...
@@ -55,6 +58,10 @@ class Projects::CommitController < Projects::ApplicationController
render
layout:
false
end
def
revert
end
private
def
commit
...
...
app/helpers/commits_helper.rb
View file @
34e26b82
...
...
@@ -123,6 +123,13 @@ module CommitsHelper
)
end
def
can_collaborate_with_project?
(
project
=
nil
)
project
||=
@project
can?
(
current_user
,
:push_code
,
project
)
||
(
current_user
&&
current_user
.
already_forked?
(
project
))
end
protected
# Private: Returns a link to a person. If the person has a matching user and
...
...
app/views/projects/commit/_commit_box.html.haml
View file @
34e26b82
...
...
@@ -16,8 +16,17 @@
=
link_to
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@commit
),
class:
"btn btn-grouped"
do
=
icon
(
'files-o'
)
Browse Files
=
link_to
'#modal-revert-commit'
,
{
'data-target'
=>
'#modal-revert-commit'
,
'data-toggle'
=>
'modal'
,
class:
'btn btn-grouped'
}
do
Revert
-
if
can_collaborate_with_project?
=
link_to
'#modal-revert-commit'
,
{
'data-target'
=>
'#modal-revert-commit'
,
'data-toggle'
=>
'modal'
,
class:
'btn btn-grouped'
}
do
Revert
-
else
-
continue_params
=
{
to:
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
@commit
.
id
),
notice:
edit_in_new_fork_notice
,
notice_now:
edit_in_new_fork_notice_now
}
-
fork_path
=
namespace_project_forks_path
(
@project
.
namespace
,
@project
,
namespace_key:
current_user
.
namespace
.
id
,
continue:
continue_params
)
=
link_to
fork_path
,
{
class:
'btn btn-grouped'
,
method: :post
}
do
Revert
%div
%p
...
...
app/views/projects/commit/show.html.haml
View file @
34e26b82
...
...
@@ -12,3 +12,5 @@
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
,
project:
@project
,
diff_refs:
@diff_refs
=
render
"projects/notes/notes_with_form"
-
if
can_collaborate_with_project?
=
render
"projects/commit/revert"
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