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
78d620b3
Commit
78d620b3
authored
Mar 29, 2012
by
randx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raw gitlab automerge feature
parent
8ee0993f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+17
-1
config/routes.rb
config/routes.rb
+1
-0
lib/gitlab_merge.rb
lib/gitlab_merge.rb
+26
-0
No files found.
app/controllers/merge_requests_controller.rb
View file @
78d620b3
...
@@ -2,7 +2,7 @@ class MergeRequestsController < ApplicationController
...
@@ -2,7 +2,7 @@ class MergeRequestsController < ApplicationController
before_filter
:authenticate_user!
before_filter
:authenticate_user!
before_filter
:project
before_filter
:project
before_filter
:module_enabled
before_filter
:module_enabled
before_filter
:merge_request
,
:only
=>
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
]
before_filter
:merge_request
,
:only
=>
[
:edit
,
:update
,
:destroy
,
:show
,
:commits
,
:diffs
,
:automerge
]
layout
"project"
layout
"project"
# Authorize
# Authorize
...
@@ -95,6 +95,22 @@ class MergeRequestsController < ApplicationController
...
@@ -95,6 +95,22 @@ class MergeRequestsController < ApplicationController
end
end
end
end
def
automerge
message
=
""
if
GitlabMerge
.
new
(
@merge_request
).
merge
@merge_request
.
update_attributes
(
:author_id_of_changes
=>
current_user
.
id
,
:closed
=>
true
)
@merge_request
.
reload_code
message
=
"Successfully merged"
else
message
=
"Can not be merged"
end
redirect_to
[
@merge_request
.
project
,
@merge_request
],
:alert
=>
message
end
def
destroy
def
destroy
@merge_request
.
destroy
@merge_request
.
destroy
...
...
config/routes.rb
View file @
78d620b3
...
@@ -102,6 +102,7 @@ Gitlab::Application.routes.draw do
...
@@ -102,6 +102,7 @@ Gitlab::Application.routes.draw do
resources
:merge_requests
do
resources
:merge_requests
do
member
do
member
do
get
:diffs
get
:diffs
get
:automerge
end
end
collection
do
collection
do
...
...
lib/gitlab_merge.rb
0 → 100644
View file @
78d620b3
class
GitlabMerge
attr_accessor
:project
,
:merge_path
,
:merge_request
def
initialize
(
merge_request
)
self
.
merge_request
=
merge_request
self
.
project
=
merge_request
.
project
self
.
merge_path
=
File
.
join
(
Rails
.
root
,
"tmp"
,
"merge_repo"
,
project
.
path
)
FileUtils
.
rm_rf
(
merge_path
)
FileUtils
.
mkdir_p
merge_path
end
def
merge
self
.
project
.
repo
.
git
.
clone
({
:branch
=>
merge_request
.
target_branch
},
project
.
url_to_repo
,
merge_path
)
output
=
""
Dir
.
chdir
(
merge_path
)
do
merge_repo
=
Grit
::
Repo
.
new
(
'.'
)
output
=
merge_repo
.
git
.
pull
({},
"origin"
,
merge_request
.
source_branch
)
if
output
=~
/Automatic merge failed/
return
false
else
merge_repo
.
git
.
push
({},
"origin"
,
merge_request
.
target_branch
)
return
true
end
end
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