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
37afaaee
Commit
37afaaee
authored
Dec 20, 2021
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import Geo repository using git clone
parent
043a8f97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
app/models/repository.rb
app/models/repository.rb
+4
-0
ee/app/services/geo/repository_base_sync_service.rb
ee/app/services/geo/repository_base_sync_service.rb
+11
-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
No files found.
app/models/repository.rb
View file @
37afaaee
...
...
@@ -941,6 +941,10 @@ class Repository
end
end
def
clone_as_mirror
(
url
,
http_authorization_header:
""
)
import_repository
(
url
,
http_authorization_header:
http_authorization_header
)
end
def
fetch_as_mirror
(
url
,
forced:
false
,
refmap: :all_refs
,
prune:
true
,
http_authorization_header:
""
)
fetch_remote
(
url
,
refmap:
refmap
,
forced:
forced
,
prune:
prune
,
http_authorization_header:
http_authorization_header
)
end
...
...
ee/app/services/geo/repository_base_sync_service.rb
View file @
37afaaee
...
...
@@ -59,7 +59,9 @@ module Geo
elsif
repository
.
exists?
fetch_geo_mirror
(
repository
)
else
ensure_repository
clone_geo_mirror
(
repository
)
repository
.
expire_status_cache
# after_create
# Because we ensure a repository exists by this point, we need to
# mark it as new, even if fetching the mirror fails, we should run
# housekeeping to enable object deduplication to run
...
...
@@ -98,11 +100,19 @@ module Geo
::
Gitlab
::
Geo
.
current_node
end
# Update an existing repository using special credentials
# @param [Repository] repository
def
fetch_geo_mirror
(
repository
)
# Fetch the repository, using a JWT header for authentication
repository
.
fetch_as_mirror
(
remote_url
,
forced:
true
,
http_authorization_header:
jwt_authentication_header
)
end
# Clone a new repository using Geo special credentials
# @param [Repository] repository
def
clone_geo_mirror
(
repository
)
repository
.
clone_as_mirror
(
remote_url
,
http_authorization_header:
jwt_authentication_header
)
end
# Build a JWT header for authentication
def
jwt_authentication_header
::
Gitlab
::
Geo
::
RepoSyncRequest
.
new
(
...
...
lib/gitlab/git/repository.rb
View file @
37afaaee
...
...
@@ -841,11 +841,11 @@ module Gitlab
end
end
def
import_repository
(
url
)
def
import_repository
(
url
,
http_authorization_header:
""
)
raise
ArgumentError
,
"don't use disk paths with import_repository:
#{
url
.
inspect
}
"
if
url
.
start_with?
(
'.'
,
'/'
)
wrapped_gitaly_errors
do
gitaly_repository_client
.
import_repository
(
url
)
gitaly_repository_client
.
import_repository
(
url
,
http_authorization_header:
http_authorization_header
)
end
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
37afaaee
...
...
@@ -145,10 +145,11 @@ module Gitlab
)
end
def
import_repository
(
source
)
def
import_repository
(
source
,
http_authorization_header:
''
)
request
=
Gitaly
::
CreateRepositoryFromURLRequest
.
new
(
repository:
@gitaly_repo
,
url:
source
url:
source
,
http_authorization_header:
http_authorization_header
)
GitalyClient
.
call
(
...
...
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