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
d3b93a6a
Commit
d3b93a6a
authored
Feb 07, 2018
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate Gitaly's RepositoryService.IsSquashInProgress RPC
parent
cdb66c02
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
25 deletions
+80
-25
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+7
-1
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+17
-0
spec/ee/spec/models/ee/merge_request_spec.rb
spec/ee/spec/models/ee/merge_request_spec.rb
+29
-23
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+26
-0
No files found.
GITALY_SERVER_VERSION
View file @
d3b93a6a
0.8
1
.0
0.8
2
.0
lib/gitlab/git/repository.rb
View file @
d3b93a6a
...
...
@@ -1234,7 +1234,13 @@ module Gitlab
end
def
squash_in_progress?
(
squash_id
)
fresh_worktree?
(
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
))
gitaly_migrate
(
:squash_in_progress
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
squash_in_progress?
(
squash_id
)
else
fresh_worktree?
(
worktree_path
(
SQUASH_WORKTREE_PREFIX
,
squash_id
))
end
end
end
def
push_remote_branches
(
remote_name
,
branch_names
,
forced:
true
)
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
d3b93a6a
...
...
@@ -134,6 +134,23 @@ module Gitlab
response
.
in_progress
end
def
squash_in_progress?
(
squash_id
)
request
=
Gitaly
::
IsSquashInProgressRequest
.
new
(
repository:
@gitaly_repo
,
squash_id:
squash_id
.
to_s
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:is_squash_in_progress
,
request
,
timeout:
GitalyClient
.
default_timeout
)
response
.
in_progress
end
def
fetch_source_branch
(
source_repository
,
source_branch
,
local_ref
)
request
=
Gitaly
::
FetchSourceBranchRequest
.
new
(
repository:
@gitaly_repo
,
...
...
spec/ee/spec/models/ee/merge_request_spec.rb
View file @
d3b93a6a
...
...
@@ -14,38 +14,44 @@ describe MergeRequest do
end
describe
'#squash_in_progress?'
do
# Create merge request and project before we stub file calls
before
do
subject
end
shared_examples
'checking whether a squash is in progress'
do
let
(
:repo_path
)
{
subject
.
source_project
.
repository
.
path
}
let
(
:squash_path
)
{
File
.
join
(
repo_path
,
"gitlab-worktree"
,
"squash-
#{
subject
.
id
}
"
)
}
it
'returns true when there is a current squash directory'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:mtime
).
and_return
(
Time
.
now
)
before
do
system
(
*
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
-C
#{
repo_path
}
worktree add --detach
#{
squash_path
}
master)
)
end
expect
(
subject
.
squash_in_progress?
).
to
be_truthy
end
it
'returns true when there is a current squash directory'
do
expect
(
subject
.
squash_in_progress?
).
to
be_truthy
end
it
'returns false when there is no squash directory'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
false
)
it
'returns false when there is no squash directory'
do
FileUtils
.
rm_rf
(
squash_path
)
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
end
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
end
it
'returns false when the squash directory has expired'
do
time
=
20
.
minutes
.
ago
.
to_time
File
.
utime
(
time
,
time
,
squash_path
)
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
end
it
'returns false when the squash directory has expired'
do
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:mtime
).
and_return
(
20
.
minutes
.
ago
)
it
'returns false when the source project has been removed'
do
allow
(
subject
).
to
receive
(
:source_project
).
and_return
(
nil
)
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
end
end
it
'returns false when the source project has been removed'
do
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
)
context
'when Gitaly squash_in_progress is enabled'
do
it_behaves_like
'checking whether a squash is in progress'
end
expect
(
File
).
not_to
have_received
(
:exist?
)
expect
(
subject
.
squash_in_progress?
).
to
be_falsey
context
'when Gitaly squash_in_progress is disabled'
,
:disable_gitaly
do
it_behaves_like
'checking whether a squash is in progress'
end
end
...
...
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
View file @
d3b93a6a
...
...
@@ -84,4 +84,30 @@ describe Gitlab::GitalyClient::RepositoryService do
expect
(
client
.
has_local_branches?
).
to
be
(
true
)
end
end
describe
'#rebase_in_progress?'
do
let
(
:rebase_id
)
{
1
}
it
'sends a repository_rebase_in_progress message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:is_rebase_in_progress
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
in_progress:
true
))
client
.
rebase_in_progress?
(
rebase_id
)
end
end
describe
'#squash_in_progress?'
do
let
(
:squash_id
)
{
1
}
it
'sends a repository_squash_in_progress message'
do
expect_any_instance_of
(
Gitaly
::
RepositoryService
::
Stub
)
.
to
receive
(
:is_squash_in_progress
)
.
with
(
gitaly_request_with_path
(
storage_name
,
relative_path
),
kind_of
(
Hash
))
.
and_return
(
double
(
in_progress:
true
))
client
.
squash_in_progress?
(
squash_id
)
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