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
d7511a4b
Commit
d7511a4b
authored
Dec 03, 2015
by
Rubén Dávila
Committed by
Robert Speicher
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create reverse branch and generate MR with new branch. #3409
parent
d3c24373
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+12
-2
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/models/repository.rb
app/models/repository.rb
+4
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
d7511a4b
...
@@ -2,7 +2,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -2,7 +2,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action
:module_enabled
before_action
:module_enabled
before_action
:merge_request
,
only:
[
before_action
:merge_request
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
,
:merge
,
:merge_check
,
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
,
:merge
,
:merge_check
,
:ci_status
,
:toggle_subscription
,
:cancel_merge_when_build_succeeds
:ci_status
,
:toggle_subscription
,
:cancel_merge_when_build_succeeds
,
:revert
]
]
before_action
:closes_issues
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:closes_issues
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
]
...
@@ -192,7 +193,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -192,7 +193,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
revert
def
revert
redirect_to
new_namespace_project_merge_request_url
(
@project
.
namespace
,
@project
)
@repository
.
find_or_create_branch
(
@merge_request
.
reverse_branch_name
,
@merge_request
.
target_branch
)
url_params
=
{
merge_request:
{
source_branch:
@merge_request
.
reverse_branch_name
,
target_branch:
@merge_request
.
target_branch
,
source_project_id:
@merge_request
.
target_project_id
,
target_project_id:
@merge_request
.
target_project_id
}}
redirect_to
new_namespace_project_merge_request_url
(
@project
.
namespace
,
@project
,
url_params
)
end
end
def
branch_from
def
branch_from
...
...
app/models/merge_request.rb
View file @
d7511a4b
...
@@ -532,4 +532,8 @@ class MergeRequest < ActiveRecord::Base
...
@@ -532,4 +532,8 @@ class MergeRequest < ActiveRecord::Base
[
diff_base_commit
,
last_commit
]
[
diff_base_commit
,
last_commit
]
end
end
def
reverse_branch_name
"revert-
#{
id
}
-
#{
target_branch
}
"
end
end
end
app/models/repository.rb
View file @
d7511a4b
...
@@ -137,6 +137,10 @@ class Repository
...
@@ -137,6 +137,10 @@ class Repository
find_branch
(
branch_name
)
find_branch
(
branch_name
)
end
end
def
find_or_create_branch
(
name
,
ref
)
find_branch
(
name
)
or
add_branch
(
name
,
ref
)
end
def
add_tag
(
tag_name
,
ref
,
message
=
nil
)
def
add_tag
(
tag_name
,
ref
,
message
=
nil
)
expire_tags_cache
expire_tags_cache
...
...
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