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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e4f5b6df
Commit
e4f5b6df
authored
Nov 28, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do a simpler rebase, show rebase check box only for users how can push code.
parent
267896c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
+17
-9
app/helpers/branches_helper.rb
app/helpers/branches_helper.rb
+10
-0
app/views/projects/merge_requests/show/_mr_accept.html.haml
app/views/projects/merge_requests/show/_mr_accept.html.haml
+1
-1
lib/gitlab/satellite/merge_action.rb
lib/gitlab/satellite/merge_action.rb
+6
-8
No files found.
app/helpers/branches_helper.rb
View file @
e4f5b6df
...
@@ -19,4 +19,14 @@ module BranchesHelper
...
@@ -19,4 +19,14 @@ module BranchesHelper
current_user
.
can?
(
action
,
project
)
current_user
.
can?
(
action
,
project
)
end
end
def
can_rebase?
(
project
,
branch_name
)
if
project
.
protected_branch?
branch_name
can?
(
current_user
,
:push_code_to_protected_branches
,
project
)
elsif
can?
(
current_user
,
:push_code
,
project
)
true
else
false
end
end
end
end
app/views/projects/merge_requests/show/_mr_accept.html.haml
View file @
e4f5b6df
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
=
label_tag
:should_remove_source_branch
,
class:
"checkbox"
do
=
label_tag
:should_remove_source_branch
,
class:
"checkbox"
do
=
check_box_tag
:should_remove_source_branch
=
check_box_tag
:should_remove_source_branch
Remove source-branch
Remove source-branch
-
if
@merge_request
.
source_project
.
merge_requests_rebase_enabled
&&
!
@merge_request
.
for_fork?
-
if
@merge_request
.
target_project
.
merge_requests_rebase_enabled
&&
can_rebase?
(
@merge_request
.
target_project
,
@merge_request
.
target_branch
)
.remove_branch_holder.pull-left
.remove_branch_holder.pull-left
=
label_tag
:should_rebase
,
class:
"checkbox"
do
=
label_tag
:should_rebase
,
class:
"checkbox"
do
=
check_box_tag
:should_rebase
=
check_box_tag
:should_rebase
...
...
lib/gitlab/satellite/merge_action.rb
View file @
e4f5b6df
...
@@ -35,7 +35,6 @@ module Gitlab
...
@@ -35,7 +35,6 @@ module Gitlab
# If unsuccesful, continue with regular merge.
# If unsuccesful, continue with regular merge.
if
merge_request
.
should_rebase
if
merge_request
.
should_rebase
if
rebase_in_satellite!
(
merge_repo
)
if
rebase_in_satellite!
(
merge_repo
)
merge_repo
.
git
.
push
(
default_options
,
:origin
,
merge_request
.
target_branch
)
remove_source_branch
(
merge_repo
)
remove_source_branch
(
merge_repo
)
return
true
return
true
end
end
...
@@ -154,21 +153,20 @@ module Gitlab
...
@@ -154,21 +153,20 @@ module Gitlab
# target_branch: master
# target_branch: master
#
#
# git checkout feature
# git checkout feature
# git merge master
# git pull --rebase origin master
# git rebase master
# git push origin feature:master
# git checkout master
# git merge feature
# git merge feature
# git push remote master
# git push remote master
def
rebase_in_satellite!
(
repo
)
def
rebase_in_satellite!
(
repo
)
update_satellite_source_and_target!
(
repo
)
update_satellite_source_and_target!
(
repo
)
repo
.
git
.
checkout
(
default_options
({
b:
true
}),
merge_request
.
source_branch
,
"source/
#{
merge_request
.
source_branch
}
"
)
repo
.
git
.
checkout
(
default_options
({
b:
true
}),
merge_request
.
source_branch
,
"source/
#{
merge_request
.
source_branch
}
"
)
repo
.
git
.
merge
(
default_options
({
no_ff:
true
}),
"origin/
#{
merge_request
.
target_branch
}
"
)
output
,
status
=
popen
(
%W(git
rebase origin/
#{
merge_request
.
target_branch
}
)
,
repo
.
working_dir
)
output
,
status
=
popen
(
%W(git
pull --rebase origin
#{
merge_request
.
target_branch
}
)
,
repo
.
working_dir
)
if
status
==
0
if
status
==
0
Gitlab
::
AppLogger
.
info
"Rebasing before merge in
#{
merge_request
.
source_project
.
path_with_namespace
}
MR!
#{
merge_request
.
id
}
:
#{
output
}
."
Gitlab
::
AppLogger
.
info
"Rebasing before merge in
#{
merge_request
.
source_project
.
path_with_namespace
}
MR!
#{
merge_request
.
id
}
:
#{
output
}
."
repo
.
git
.
checkout
(
default_options
,
merge_request
.
target_branch
)
if
merge_request
.
source_branch
&&
merge_request
.
target_branch
repo
.
git
.
merge
(
default_options
,
"source/
#{
merge_request
.
source_branch
}
"
)
repo
.
git
.
push
(
default_options
,
"origin"
,
"
#{
merge_request
.
source_branch
}
:
#{
merge_request
.
target_branch
}
"
)
end
else
else
repo
.
git
.
rebase
(
default_options
,
"--abort"
)
repo
.
git
.
rebase
(
default_options
,
"--abort"
)
Gitlab
::
AppLogger
.
info
"Rebasing in in
#{
merge_request
.
source_project
.
path_with_namespace
}
MR!
#{
merge_request
.
id
}
aborted, rebase manually."
Gitlab
::
AppLogger
.
info
"Rebasing in in
#{
merge_request
.
source_project
.
path_with_namespace
}
MR!
#{
merge_request
.
id
}
aborted, rebase manually."
...
...
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