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
Boxiang Sun
gitlab-ce
Commits
207522f9
Commit
207522f9
authored
Feb 01, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some refactor to the revert commit creation.
* Not required to run hooks since it's an internal commit
parent
f56ee9d3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
17 deletions
+20
-17
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+2
-2
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+17
-14
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
207522f9
...
@@ -193,10 +193,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -193,10 +193,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
revert
def
revert
@repository
.
revert_merge
(
current_user
,
@merge_request
.
merge_commit_sha
,
@merge_request
.
reverse_branch_name
)
@repository
.
revert_merge
(
current_user
,
@merge_request
)
url_params
=
{
merge_request:
{
url_params
=
{
merge_request:
{
source_branch:
@merge_request
.
rever
se
_branch_name
,
source_branch:
@merge_request
.
rever
t
_branch_name
,
target_branch:
@merge_request
.
target_branch
,
target_branch:
@merge_request
.
target_branch
,
source_project_id:
@merge_request
.
target_project_id
,
source_project_id:
@merge_request
.
target_project_id
,
target_project_id:
@merge_request
.
target_project_id
target_project_id:
@merge_request
.
target_project_id
...
...
app/models/merge_request.rb
View file @
207522f9
...
@@ -534,7 +534,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -534,7 +534,7 @@ class MergeRequest < ActiveRecord::Base
[
diff_base_commit
,
last_commit
]
[
diff_base_commit
,
last_commit
]
end
end
def
rever
se
_branch_name
def
rever
t
_branch_name
"revert-
#{
id
}
-
#{
target_branch
}
"
"revert-
#{
id
}
-
#{
target_branch
}
"
end
end
end
end
app/models/repository.rb
View file @
207522f9
...
@@ -626,27 +626,30 @@ class Repository
...
@@ -626,27 +626,30 @@ class Repository
merge_commit_sha
merge_commit_sha
end
end
def
revert_merge
(
user
,
merge_commit_id
,
revert_branch_name
)
def
revert_merge
(
user
,
merge_request
)
find_or_create_branch
(
user
,
revert_branch_name
,
merge_commit_id
)
revert_branch_name
=
merge_request
.
revert_branch_name
merge_commit_id
=
merge_request
.
merge_commit_sha
# branch exists and it's highly probable that it has the revert commit
return
if
find_branch
(
revert_branch_name
)
add_branch
(
user
,
revert_branch_name
,
merge_commit_id
)
new_index
=
rugged
.
revert_commit
(
merge_commit_id
,
merge_commit_id
,
mainline:
1
)
new_index
=
rugged
.
revert_commit
(
merge_commit_id
,
merge_commit_id
,
mainline:
1
)
committer
=
user_to_committer
(
user
)
committer
=
user_to_committer
(
user
)
commit_with_hooks
(
user
,
revert_branch_name
)
do
|
ref
|
options
=
{
options
=
{
message:
'Revert MR'
,
message:
"Revert
\"
#{
merge_request
.
title
}
\"
"
,
author:
committer
,
author:
committer
,
committer:
committer
,
committer:
committer
,
tree:
new_index
.
write_tree
(
rugged
),
tree:
new_index
.
write_tree
(
rugged
),
parents:
[
rugged
.
lookup
(
merge_commit_id
)],
parents:
[
rugged
.
lookup
(
merge_commit_id
)],
update_ref:
ref
update_ref:
"refs/heads/
#{
revert_branch_name
}
"
}
}
Rugged
::
Commit
.
create
(
rugged
,
options
)
Rugged
::
Commit
.
create
(
rugged
,
options
)
end
end
end
def
merged_to_root_ref?
(
branch_name
)
def
merged_to_root_ref?
(
branch_name
)
branch_commit
=
commit
(
branch_name
)
branch_commit
=
commit
(
branch_name
)
root_ref_commit
=
commit
(
root_ref
)
root_ref_commit
=
commit
(
root_ref
)
...
...
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