BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
92d62ff6
Commit
92d62ff6
authored
Jan 08, 2018
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate rebase_in_progress? to Gitaly
Closes gitaly#866
parent
be623ef3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
11 deletions
+40
-11
repository.rb
lib/gitlab/git/repository.rb
+6
-0
repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+17
-0
merge_request_spec.rb
spec/models/merge_request_spec.rb
+17
-11
No files found.
lib/gitlab/git/repository.rb
View file @
92d62ff6
...
@@ -1234,8 +1234,14 @@ module Gitlab
...
@@ -1234,8 +1234,14 @@ module Gitlab
end
end
def
rebase_in_progress?
(
rebase_id
)
def
rebase_in_progress?
(
rebase_id
)
gitaly_migrate
(
:rebase_in_progress
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
rebase_in_progress?
(
rebase_id
)
else
fresh_worktree?
(
worktree_path
(
REBASE_WORKTREE_PREFIX
,
rebase_id
))
fresh_worktree?
(
worktree_path
(
REBASE_WORKTREE_PREFIX
,
rebase_id
))
end
end
end
end
def
squash
(
user
,
squash_id
,
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
def
squash
(
user
,
squash_id
,
branch
:,
start_sha
:,
end_sha
:,
author
:,
message
:)
squash_path
=
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
)
squash_path
=
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
)
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
92d62ff6
...
@@ -100,6 +100,23 @@ module Gitlab
...
@@ -100,6 +100,23 @@ module Gitlab
)
)
end
end
def
rebase_in_progress?
(
rebase_id
)
request
=
Gitaly
::
IsRebaseInProgressRequest
.
new
(
repository:
@gitaly_repo
,
rebase_id:
rebase_id
.
to_s
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:is_rebase_in_progress
,
request
,
timeout:
GitalyClient
.
default_timeout
)
response
.
in_progress
end
def
fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
def
fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
request
=
Gitaly
::
FetchSourceBranchRequest
.
new
(
request
=
Gitaly
::
FetchSourceBranchRequest
.
new
(
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
...
...
spec/models/merge_request_spec.rb
View file @
92d62ff6
...
@@ -1915,38 +1915,44 @@ describe MergeRequest do
...
@@ -1915,38 +1915,44 @@ describe MergeRequest do
end
end
describe
'#rebase_in_progress?'
do
describe
'#rebase_in_progress?'
do
# Create merge request and project before we stub file calls
shared_examples
'checking whether a rebase is in progress'
do
let
(
:repo_path
)
{
subject
.
source_project
.
repository
.
path
}
let
(
:rebase_path
)
{
File
.
join
(
repo_path
,
"gitlab-worktree"
,
"rebase-
#{
subject
.
id
}
"
)
}
before
do
before
do
subject
system
(
*
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
-C
#{
repo_path
}
worktree add --detach
#{
rebase_path
}
master)
)
end
end
it
'returns true when there is a current rebase directory'
do
it
'returns true when there is a current rebase directory'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:mtime
).
and_return
(
Time
.
now
)
expect
(
subject
.
rebase_in_progress?
).
to
be_truthy
expect
(
subject
.
rebase_in_progress?
).
to
be_truthy
end
end
it
'returns false when there is no rebase directory'
do
it
'returns false when there is no rebase directory'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
false
)
FileUtils
.
rm_rf
(
rebase_path
)
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
end
end
it
'returns false when the rebase directory has expired'
do
it
'returns false when the rebase directory has expired'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
time
=
20
.
minutes
.
ago
.
to_time
allow
(
File
).
to
receive
(
:mtime
).
and_return
(
20
.
minutes
.
ago
)
File
.
utime
(
time
,
time
,
rebase_path
)
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
end
end
it
'returns false when the source project has been removed'
do
it
'returns false when the source project has been removed'
do
allow
(
subject
).
to
receive
(
:source_project
).
and_return
(
nil
)
allow
(
subject
).
to
receive
(
:source_project
).
and_return
(
nil
)
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:mtime
).
and_return
(
Time
.
now
)
expect
(
File
).
not_to
have_received
(
:exist?
)
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
expect
(
subject
.
rebase_in_progress?
).
to
be_falsey
end
end
end
end
context
'when Gitaly rebase_in_progress is enabled'
do
it_behaves_like
'checking whether a rebase is in progress'
end
context
'when Gitaly rebase_in_progress is enabled'
,
:disable_gitaly
do
it_behaves_like
'checking whether a rebase is in progress'
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