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
74d435c6
Commit
74d435c6
authored
Sep 19, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using worktrees and git operations service to update ref after rebasing
parent
423f153d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
13 deletions
+21
-13
app/services/merge_requests/rebase_service.rb
app/services/merge_requests/rebase_service.rb
+10
-12
changelogs/unreleased-ee/rebase_using_custom_worktree.yml
changelogs/unreleased-ee/rebase_using_custom_worktree.yml
+5
-0
lib/gitlab/git/operation_service.rb
lib/gitlab/git/operation_service.rb
+5
-0
spec/services/merge_requests/rebase_service_spec.rb
spec/services/merge_requests/rebase_service_spec.rb
+1
-1
No files found.
app/services/merge_requests/rebase_service.rb
View file @
74d435c6
...
...
@@ -17,14 +17,14 @@ module MergeRequests
end
run_git_command
(
%W(
clone -b
#{
merge_request
.
source_branch
}
--
#{
source_project
.
repository
.
path_to_repo
}
#{
tree_pat
h
}
)
,
nil
,
%W(
worktree add --detach
#{
tree_path
}
#{
merge_request
.
source_branc
h
}
)
,
repository
.
path_to_repo
,
git_env
,
'
clone repository
for rebase'
'
add worktree
for rebase'
)
run_git_command
(
%W(
pull --rebase
#{
target_project
.
repository
.
path_to_repo
}
#{
merge_request
.
target_branch
}
)
,
%W(
rebase
#{
merge_request
.
target_branch
}
)
,
tree_path
,
git_env
.
merge
(
'GIT_COMMITTER_NAME'
=>
current_user
.
name
,
'GIT_COMMITTER_EMAIL'
=>
current_user
.
email
),
...
...
@@ -32,20 +32,16 @@ module MergeRequests
)
rebase_sha
=
run_git_command
(
%
W(rev-parse
#{
merge_request
.
source_branch
}
)
,
%
w(rev-parse HEAD
)
,
tree_path
,
git_env
,
'get SHA of rebased branch'
)
merge_request
.
update_attributes
(
rebase_commit_sha:
rebase_sha
)
Gitlab
::
Git
::
OperationService
.
new
(
current_user
,
project
.
repository
.
raw_repository
)
.
update_branch
(
merge_request
.
source_branch
,
rebase_sha
,
merge_request
.
source_branch_sha
)
run_git_command
(
%W(push -f origin
#{
merge_request
.
source_branch
}
)
,
tree_path
,
git_env
,
'push rebased branch'
)
merge_request
.
update_attributes
(
rebase_commit_sha:
rebase_sha
)
true
rescue
GitCommandError
...
...
@@ -58,6 +54,8 @@ module MergeRequests
clean_dir
end
private
def
tree_path
@tree_path
||=
merge_request
.
rebase_dir_path
end
...
...
changelogs/unreleased-ee/rebase_using_custom_worktree.yml
0 → 100644
View file @
74d435c6
---
title
:
Improve performance of rebasing by using worktree
merge_request
:
author
:
type
:
changed
lib/gitlab/git/operation_service.rb
View file @
74d435c6
...
...
@@ -91,6 +91,11 @@ module Gitlab
end
end
def
update_branch
(
branch_name
,
newrev
,
oldrev
)
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch_name
update_ref_in_hooks
(
ref
,
newrev
,
oldrev
)
end
private
# Returns [newrev, should_run_after_create, should_run_after_create_branch]
...
...
spec/services/merge_requests/rebase_service_spec.rb
View file @
74d435c6
...
...
@@ -95,7 +95,7 @@ describe MergeRequests::RebaseService do
context
'git commands'
do
it
'sets GL_REPOSITORY env variable when calling git commands'
do
expect_any_instance_of
(
described_class
)
.
to
receive
(
:run_git_command
).
exactly
(
4
).
with
(
.
to
receive
(
:run_git_command
).
exactly
(
3
).
with
(
anything
,
anything
,
hash_including
(
'GL_REPOSITORY'
),
...
...
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