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
a28eef1d
Commit
a28eef1d
authored
Feb 08, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update copy and URLs used when reverting MRs.
parent
38752d15
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+23
-3
app/models/commit.rb
app/models/commit.rb
+6
-0
app/services/commits/revert_service.rb
app/services/commits/revert_service.rb
+1
-1
No files found.
app/controllers/projects/commit_controller.rb
View file @
a28eef1d
...
...
@@ -62,13 +62,32 @@ class Projects::CommitController < Projects::ApplicationController
def
revert
return
render_404
if
@target_branch
.
blank?
create_commit
(
Commits
::
RevertService
,
success_notice:
"The commit has been successfully reverted."
,
success_path:
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@target_branch
),
failure_path:
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
params
[
:id
]))
create_commit
(
Commits
::
RevertService
,
success_notice:
"The
#{
revert_type_title
}
has been successfully reverted."
,
success_path:
successful_revert_path
,
failure_path:
failed_revert_path
)
end
private
def
revert_type_title
@commit
.
merged_merge_request
?
'merge request'
:
'commit'
end
def
successful_revert_path
return
referenced_merge_request_url
if
@commit
.
merged_merge_request
namespace_project_commits_url
(
@project
.
namespace
,
@project
,
@target_branch
)
end
def
failed_revert_path
return
referenced_merge_request_url
if
@commit
.
merged_merge_request
namespace_project_commit_url
(
@project
.
namespace
,
@project
,
params
[
:id
])
end
def
referenced_merge_request_url
namespace_project_merge_request_url
(
@project
.
namespace
,
@project
,
@commit
.
merged_merge_request
)
end
def
commit
@commit
||=
@project
.
commit
(
params
[
:id
])
end
...
...
@@ -99,6 +118,7 @@ class Projects::CommitController < Projects::ApplicationController
@mr_target_branch
=
@target_branch
@commit_params
=
{
commit:
@commit
,
revert_type_title:
revert_type_title
,
create_merge_request:
params
[
:create_merge_request
].
present?
||
different_project?
}
end
...
...
app/models/commit.rb
View file @
a28eef1d
...
...
@@ -227,6 +227,12 @@ class Commit
parents
.
size
>
1
end
def
merged_merge_request
return
@merged_merge_request
if
defined?
(
@merged_merge_request
)
@merged_merge_request
=
is_a_merge_commit?
&&
MergeRequest
.
where
(
merge_commit_sha:
id
).
first
end
private
def
repo_changes
...
...
app/services/commits/revert_service.rb
View file @
a28eef1d
...
...
@@ -14,7 +14,7 @@ module Commits
if
commit
success
else
error
(
"Sorry, we cannot revert this
commit
automatically.
error
(
"Sorry, we cannot revert this
#{
params
[
:revert_type_title
]
}
automatically.
It may have already been reverted, or a more recent commit may
have updated some of its content."
)
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