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
Kazuhiko Shiozaki
gitlab-ce
Commits
b6fe51b9
Commit
b6fe51b9
authored
Feb 02, 2016
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some updates from last code review.
parent
1708e1fc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
29 deletions
+30
-29
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+11
-11
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/models/repository.rb
app/models/repository.rb
+15
-13
app/views/projects/merge_requests/show/_mr_title.html.haml
app/views/projects/merge_requests/show/_mr_title.html.haml
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+0
-1
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
b6fe51b9
...
@@ -193,18 +193,18 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -193,18 +193,18 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
revert
def
revert
target_branch_exists
=
@merge_request
.
target_branch_exists?
url_params
=
{
url_params
=
{
merge_request:
{
merge_request:
{
source_branch:
@merge_request
.
revert_branch_name
,
source_branch:
@merge_request
.
revert_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
,
description:
@merge_request
.
revert_description
}
description:
@merge_request
.
revert_description
}
}}
if
@merge_request
.
target_branch_exists?
&&
@merge_request
.
merge_commit_sha
.
present?
if
target_branch_exists
@repository
.
revert_merge
(
current_user
,
@merge_request
.
merge_commit_sha
,
@repository
.
revert_merge
(
current_user
,
@merge_request
.
merge_commit_sha
,
@merge_request
.
revert_branch_name
,
@merge_request
.
revert_title
)
@merge_request
.
revert_branch_name
,
@merge_request
.
target_branch
,
@merge_request
.
revert_title
)
redirect_to
new_namespace_project_merge_request_url
(
@project
.
namespace
,
@project
,
url_params
)
redirect_to
new_namespace_project_merge_request_url
(
@project
.
namespace
,
@project
,
url_params
)
else
else
...
...
app/helpers/application_helper.rb
View file @
b6fe51b9
...
@@ -135,7 +135,7 @@ module ApplicationHelper
...
@@ -135,7 +135,7 @@ module ApplicationHelper
# Skip if user removed branch right after that
# Skip if user removed branch right after that
return
false
unless
project
.
repository
.
branch_names
.
include?
(
event
.
branch_name
)
return
false
unless
project
.
repository
.
branch_names
.
include?
(
event
.
branch_name
)
return
false
if
Gitlab
::
Git
::
REVERT_BRANCH_PATTERN
===
event
.
branch_name
return
false
if
event
.
branch_name
=~
Gitlab
::
Git
::
REVERT_BRANCH_PATTERN
true
true
end
end
...
...
app/models/merge_request.rb
View file @
b6fe51b9
...
@@ -535,11 +535,11 @@ class MergeRequest < ActiveRecord::Base
...
@@ -535,11 +535,11 @@ class MergeRequest < ActiveRecord::Base
end
end
def
revert_branch_name
def
revert_branch_name
"revert-
#{
iid
}
-
#{
target
_branch
}
"
"revert-
#{
iid
}
-
#{
source
_branch
}
"
end
end
def
revert_title
def
revert_title
"Revert
\"
#{
title
}
\"
"
"Revert
\"
#{
title
}
\"
"
end
end
def
revert_description
def
revert_description
...
...
app/models/repository.rb
View file @
b6fe51b9
...
@@ -622,25 +622,27 @@ class Repository
...
@@ -622,25 +622,27 @@ class Repository
merge_commit_sha
merge_commit_sha
end
end
def
revert_merge
(
user
,
merge_commit_id
,
new_branch_name
,
commit_message
)
def
revert_merge
(
user
,
merge_commit_id
,
new_branch_name
,
target_branch
,
commit_message
)
# branch exists and it's highly probable that it has the revert commit
# branch exists and it's highly probable that it has the revert commit
return
if
find_branch
(
new_branch_name
)
return
if
find_branch
(
new_branch_name
)
add_branch
(
user
,
new_branch_name
,
merge_commit_id
)
target_sha
=
find_branch
(
target_branch
).
target
new_index
=
rugged
.
revert_commit
(
merge_commit_id
,
merge_commit_id
,
mainline:
1
)
commit_with_hooks
(
user
,
new_branch_name
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
new_index
=
rugged
.
revert_commit
(
merge_commit_id
,
target_sha
,
mainline:
1
)
committer
=
user_to_committer
(
user
)
options
=
{
options
=
{
message:
commit_message
,
message:
commit_message
,
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
(
target_sha
)],
update_ref:
"refs/heads/
#{
new_branch_name
}
"
update_ref:
ref
}
}
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
)
...
...
app/views/projects/merge_requests/show/_mr_title.html.haml
View file @
b6fe51b9
...
@@ -18,5 +18,5 @@
...
@@ -18,5 +18,5 @@
Edit
Edit
-
if
@merge_request
.
closed?
-
if
@merge_request
.
closed?
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
'btn btn-nr btn-grouped btn-reopen reopen-mr-link'
,
title:
"Reopen merge request"
=
link_to
'Reopen'
,
merge_request_path
(
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
'btn btn-nr btn-grouped btn-reopen reopen-mr-link'
,
title:
"Reopen merge request"
-
if
@merge_request
.
merged?
-
if
@merge_request
.
merged?
&&
@merge_request
.
merge_commit_sha
.
present?
=
link_to
'Revert'
,
revert_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
method: :post
,
class:
"btn btn-grouped btn-close"
,
title:
"Revert merge request"
=
link_to
'Revert'
,
revert_namespace_project_merge_request_path
(
@project
.
namespace
,
@project
,
@merge_request
),
method: :post
,
class:
"btn btn-grouped btn-close"
,
title:
"Revert merge request"
spec/models/repository_spec.rb
View file @
b6fe51b9
...
@@ -10,7 +10,6 @@ describe Repository, models: true do
...
@@ -10,7 +10,6 @@ describe Repository, models: true do
{
message:
'Test message'
,
committer:
author
,
author:
author
}
{
message:
'Test message'
,
committer:
author
,
author:
author
}
end
end
let
(
:merge_commit_id
)
do
let
(
:merge_commit_id
)
do
master_commit
=
repository
.
commit
(
'master'
)
source_sha
=
repository
.
find_branch
(
'feature'
).
target
source_sha
=
repository
.
find_branch
(
'feature'
).
target
repository
.
merge
(
user
,
source_sha
,
'master'
,
commit_options
)
repository
.
merge
(
user
,
source_sha
,
'master'
,
commit_options
)
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