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
Jérome Perrin
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
Hide 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
...
@@ -62,13 +62,32 @@ class Projects::CommitController < Projects::ApplicationController
def
revert
def
revert
return
render_404
if
@target_branch
.
blank?
return
render_404
if
@target_branch
.
blank?
create_commit
(
Commits
::
RevertService
,
success_notice:
"The commit has been successfully reverted."
,
create_commit
(
Commits
::
RevertService
,
success_notice:
"The
#{
revert_type_title
}
has been successfully reverted."
,
success_path:
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@target_branch
),
success_path:
successful_revert_path
,
failure_path:
failed_revert_path
)
failure_path:
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
params
[
:id
]))
end
end
private
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
def
commit
@commit
||=
@project
.
commit
(
params
[
:id
])
@commit
||=
@project
.
commit
(
params
[
:id
])
end
end
...
@@ -99,6 +118,7 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -99,6 +118,7 @@ class Projects::CommitController < Projects::ApplicationController
@mr_target_branch
=
@target_branch
@mr_target_branch
=
@target_branch
@commit_params
=
{
@commit_params
=
{
commit:
@commit
,
commit:
@commit
,
revert_type_title:
revert_type_title
,
create_merge_request:
params
[
:create_merge_request
].
present?
||
different_project?
create_merge_request:
params
[
:create_merge_request
].
present?
||
different_project?
}
}
end
end
...
...
app/models/commit.rb
View file @
a28eef1d
...
@@ -227,6 +227,12 @@ class Commit
...
@@ -227,6 +227,12 @@ class Commit
parents
.
size
>
1
parents
.
size
>
1
end
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
private
def
repo_changes
def
repo_changes
...
...
app/services/commits/revert_service.rb
View file @
a28eef1d
...
@@ -14,7 +14,7 @@ module Commits
...
@@ -14,7 +14,7 @@ module Commits
if
commit
if
commit
success
success
else
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
It may have already been reverted, or a more recent commit may
have updated some of its content."
)
have updated some of its content."
)
end
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