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
99b83964
Commit
99b83964
authored
Nov 30, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decoupled model-facing logic from Gitlab::Git on squash/rebase
parent
707225fa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
17 deletions
+23
-17
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+15
-0
ee/app/services/merge_requests/rebase_service.rb
ee/app/services/merge_requests/rebase_service.rb
+1
-5
ee/app/services/merge_requests/squash_service.rb
ee/app/services/merge_requests/squash_service.rb
+1
-6
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+6
-6
No files found.
ee/app/models/ee/repository.rb
View file @
99b83964
...
@@ -38,5 +38,20 @@ module EE
...
@@ -38,5 +38,20 @@ module EE
def
delete_remote_branches
(
remote
,
branches
)
def
delete_remote_branches
(
remote
,
branches
)
gitlab_shell
.
delete_remote_branches
(
repository_storage_path
,
disk_path
,
remote
,
branches
)
gitlab_shell
.
delete_remote_branches
(
repository_storage_path
,
disk_path
,
remote
,
branches
)
end
end
def
rebase
(
user
,
merge_request
)
raw
.
rebase
(
user
,
merge_request
.
id
,
branch:
merge_request
.
source_branch
,
branch_sha:
merge_request
.
source_branch_sha
,
remote_repository:
merge_request
.
target_project
.
repository
.
raw
,
remote_branch:
merge_request
.
target_branch
)
end
def
squash
(
user
,
merge_request
)
raw
.
squash
(
user
,
merge_request
.
id
,
branch:
merge_request
.
target_branch
,
start_sha:
merge_request
.
diff_start_sha
,
end_sha:
merge_request
.
diff_head_sha
,
author:
merge_request
.
author
,
message:
merge_request
.
title
)
end
end
end
end
end
ee/app/services/merge_requests/rebase_service.rb
View file @
99b83964
...
@@ -16,11 +16,7 @@ module MergeRequests
...
@@ -16,11 +16,7 @@ module MergeRequests
return
false
return
false
end
end
rebase_sha
=
repository
.
rebase
(
current_user
,
merge_request
.
id
,
rebase_sha
=
repository
.
rebase
(
current_user
,
merge_request
)
source_branch:
merge_request
.
source_branch
,
source_branch_sha:
merge_request
.
source_branch_sha
,
target_repository:
target_project
.
repository
.
raw
,
target_branch:
merge_request
.
target_branch
)
merge_request
.
update_attributes
(
rebase_commit_sha:
rebase_sha
)
merge_request
.
update_attributes
(
rebase_commit_sha:
rebase_sha
)
...
...
ee/app/services/merge_requests/squash_service.rb
View file @
99b83964
...
@@ -22,12 +22,7 @@ module MergeRequests
...
@@ -22,12 +22,7 @@ module MergeRequests
return
error
(
'Squash task canceled: another squash is already in progress.'
)
return
error
(
'Squash task canceled: another squash is already in progress.'
)
end
end
squash_sha
=
repository
.
squash
(
current_user
,
merge_request
.
id
,
squash_sha
=
repository
.
squash
(
current_user
,
merge_request
)
target_branch:
merge_request
.
target_branch
,
start_sha:
merge_request
.
diff_start_sha
,
end_sha:
merge_request
.
diff_head_sha
,
author:
merge_request
.
author
,
message:
merge_request
.
title
)
success
(
squash_sha:
squash_sha
)
success
(
squash_sha:
squash_sha
)
rescue
=>
e
rescue
=>
e
...
...
lib/gitlab/git/repository.rb
View file @
99b83964
...
@@ -1212,20 +1212,20 @@ module Gitlab
...
@@ -1212,20 +1212,20 @@ module Gitlab
raise
GitError
.
new
(
"Could not fsck repository:
\n
#{
output
}
"
)
unless
status
.
zero?
raise
GitError
.
new
(
"Could not fsck repository:
\n
#{
output
}
"
)
unless
status
.
zero?
end
end
def
rebase
(
user
,
rebase_id
,
source_branch
:,
source_branch_sha
:,
target_repository
:,
target
_branch
:)
def
rebase
(
user
,
rebase_id
,
branch
:,
branch_sha
:,
remote_repository
:,
remote
_branch
:)
rebase_path
=
rebase_dir_path
(
rebase_id
)
rebase_path
=
rebase_dir_path
(
rebase_id
)
env
=
git_env_for_user
(
user
)
env
=
git_env_for_user
(
user
)
with_worktree
(
rebase_path
,
source_
branch
,
env:
env
)
do
with_worktree
(
rebase_path
,
branch
,
env:
env
)
do
run_git!
(
run_git!
(
%W(pull --rebase
#{
target_repository
.
path
}
#{
target
_branch
}
)
,
%W(pull --rebase
#{
remote_repository
.
path
}
#{
remote
_branch
}
)
,
chdir:
rebase_path
,
env:
env
chdir:
rebase_path
,
env:
env
)
)
rebase_sha
=
run_git!
(
%w(rev-parse HEAD)
,
chdir:
rebase_path
,
env:
env
).
strip
rebase_sha
=
run_git!
(
%w(rev-parse HEAD)
,
chdir:
rebase_path
,
env:
env
).
strip
Gitlab
::
Git
::
OperationService
.
new
(
user
,
self
)
Gitlab
::
Git
::
OperationService
.
new
(
user
,
self
)
.
update_branch
(
source_branch
,
rebase_sha
,
source_
branch_sha
)
.
update_branch
(
branch
,
rebase_sha
,
branch_sha
)
rebase_sha
rebase_sha
end
end
...
@@ -1235,7 +1235,7 @@ module Gitlab
...
@@ -1235,7 +1235,7 @@ module Gitlab
fresh_worktree?
(
rebase_dir_path
(
rebase_id
))
fresh_worktree?
(
rebase_dir_path
(
rebase_id
))
end
end
def
squash
(
user
,
squash_id
,
target_
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
def
squash
(
user
,
squash_id
,
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
squash_path
=
squash_dir_path
(
squash_id
)
squash_path
=
squash_dir_path
(
squash_id
)
env
=
git_env_for_user
(
user
).
merge
(
env
=
git_env_for_user
(
user
).
merge
(
'GIT_AUTHOR_NAME'
=>
author
.
name
,
'GIT_AUTHOR_NAME'
=>
author
.
name
,
...
@@ -1246,7 +1246,7 @@ module Gitlab
...
@@ -1246,7 +1246,7 @@ module Gitlab
%W(diff --name-only --diff-filter=a --binary
#{
diff_range
}
)
%W(diff --name-only --diff-filter=a --binary
#{
diff_range
}
)
).
chomp
).
chomp
with_worktree
(
squash_path
,
target_
branch
,
sparse_checkout_files:
diff_files
,
env:
env
)
do
with_worktree
(
squash_path
,
branch
,
sparse_checkout_files:
diff_files
,
env:
env
)
do
# Apply diff of the `diff_range` to the worktree
# Apply diff of the `diff_range` to the worktree
diff
=
run_git!
(
%W(diff --binary
#{
diff_range
}
)
)
diff
=
run_git!
(
%W(diff --binary
#{
diff_range
}
)
)
run_git!
(
%w(apply --index)
,
chdir:
squash_path
,
env:
env
)
do
|
stdin
|
run_git!
(
%w(apply --index)
,
chdir:
squash_path
,
env:
env
)
do
|
stdin
|
...
...
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