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
c98c3f1d
Commit
c98c3f1d
authored
Mar 11, 2022
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mirror flag to `import_repository`
parent
32ea462c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
7 deletions
+8
-7
app/models/repository.rb
app/models/repository.rb
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+2
-2
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+3
-2
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+1
-1
spec/models/project_import_state_spec.rb
spec/models/project_import_state_spec.rb
+1
-1
No files found.
app/models/repository.rb
View file @
c98c3f1d
...
@@ -942,7 +942,7 @@ class Repository
...
@@ -942,7 +942,7 @@ class Repository
end
end
def
clone_as_mirror
(
url
,
http_authorization_header:
""
)
def
clone_as_mirror
(
url
,
http_authorization_header:
""
)
import_repository
(
url
,
http_authorization_header:
http_authorization_header
)
import_repository
(
url
,
http_authorization_header:
http_authorization_header
,
mirror:
true
)
end
end
def
fetch_as_mirror
(
url
,
forced:
false
,
refmap: :all_refs
,
prune:
true
,
http_authorization_header:
""
)
def
fetch_as_mirror
(
url
,
forced:
false
,
refmap: :all_refs
,
prune:
true
,
http_authorization_header:
""
)
...
...
lib/gitlab/git/repository.rb
View file @
c98c3f1d
...
@@ -841,11 +841,11 @@ module Gitlab
...
@@ -841,11 +841,11 @@ module Gitlab
end
end
end
end
def
import_repository
(
url
,
http_authorization_header:
''
)
def
import_repository
(
url
,
http_authorization_header:
''
,
mirror:
false
)
raise
ArgumentError
,
"don't use disk paths with import_repository:
#{
url
.
inspect
}
"
if
url
.
start_with?
(
'.'
,
'/'
)
raise
ArgumentError
,
"don't use disk paths with import_repository:
#{
url
.
inspect
}
"
if
url
.
start_with?
(
'.'
,
'/'
)
wrapped_gitaly_errors
do
wrapped_gitaly_errors
do
gitaly_repository_client
.
import_repository
(
url
,
http_authorization_header:
http_authorization_header
)
gitaly_repository_client
.
import_repository
(
url
,
http_authorization_header:
http_authorization_header
,
mirror:
mirror
)
end
end
end
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
c98c3f1d
...
@@ -145,11 +145,12 @@ module Gitlab
...
@@ -145,11 +145,12 @@ module Gitlab
)
)
end
end
def
import_repository
(
source
,
http_authorization_header:
''
)
def
import_repository
(
source
,
http_authorization_header:
''
,
mirror:
false
)
request
=
Gitaly
::
CreateRepositoryFromURLRequest
.
new
(
request
=
Gitaly
::
CreateRepositoryFromURLRequest
.
new
(
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
url:
source
,
url:
source
,
http_authorization_header:
http_authorization_header
http_authorization_header:
http_authorization_header
,
mirror:
mirror
)
)
GitalyClient
.
call
(
GitalyClient
.
call
(
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
c98c3f1d
...
@@ -2448,7 +2448,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
...
@@ -2448,7 +2448,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
it
'delegates to Gitaly'
do
it
'delegates to Gitaly'
do
expect_next_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
)
do
|
svc
|
expect_next_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
)
do
|
svc
|
expect
(
svc
).
to
receive
(
:import_repository
).
with
(
url
,
http_authorization_header:
''
).
and_return
(
nil
)
expect
(
svc
).
to
receive
(
:import_repository
).
with
(
url
,
http_authorization_header:
''
,
mirror:
false
).
and_return
(
nil
)
end
end
repository
.
import_repository
(
url
)
repository
.
import_repository
(
url
)
...
...
spec/models/project_import_state_spec.rb
View file @
c98c3f1d
...
@@ -22,7 +22,7 @@ RSpec.describe ProjectImportState, type: :model do
...
@@ -22,7 +22,7 @@ RSpec.describe ProjectImportState, type: :model do
before
do
before
do
allow_any_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
).
to
receive
(
:import_repository
)
allow_any_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
).
to
receive
(
:import_repository
)
.
with
(
project
.
import_url
,
http_authorization_header:
''
).
and_return
(
true
)
.
with
(
project
.
import_url
,
http_authorization_header:
''
,
mirror:
false
).
and_return
(
true
)
# Works around https://github.com/rspec/rspec-mocks/issues/910
# Works around https://github.com/rspec/rspec-mocks/issues/910
allow
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
).
and_return
(
project
)
allow
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
).
and_return
(
project
)
...
...
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