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
660e23c4
Commit
660e23c4
authored
Feb 22, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Synced repository will behave as a "git clone --mirror".
Will git fetch with "--prune"
parent
8bb550ae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
app/models/repository.rb
app/models/repository.rb
+13
-0
app/workers/geo_repository_update_worker.rb
app/workers/geo_repository_update_worker.rb
+1
-3
No files found.
app/models/repository.rb
View file @
660e23c4
...
...
@@ -181,6 +181,13 @@ class Repository
raw_repository
.
remote_update
(
name
,
url:
url
)
end
def
set_remote_as_mirror
(
name
)
# This is used by Gitlab Geo to define repository as equivalent as "git clone --mirror"
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.fetch"
]
=
'refs/*:refs/*'
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.mirror"
]
=
true
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.prune"
]
=
true
end
def
fetch_remote
(
remote
)
gitlab_shell
.
fetch_remote
(
path_with_namespace
,
remote
)
end
...
...
@@ -742,6 +749,12 @@ class Repository
fetch_remote
(
Repository
::
MIRROR_REMOTE
)
end
def
fetch_geo_mirror
(
url
)
add_remote
(
Repository
::
MIRROR_REMOTE
,
url
)
set_remote_as_mirror
(
Repository
::
MIRROR_REMOTE
)
fetch_remote
(
Repository
::
MIRROR_REMOTE
)
end
def
upstream_branches
rugged
.
references
.
each
(
"refs/remotes/
#{
Repository
::
MIRROR_REMOTE
}
/*"
).
map
do
|
ref
|
name
=
ref
.
name
.
sub
(
/\Arefs\/remotes\/
#{
Repository
::
MIRROR_REMOTE
}
\//
,
""
)
...
...
app/workers/geo_repository_update_worker.rb
View file @
660e23c4
...
...
@@ -10,13 +10,11 @@ class GeoRepositoryUpdateWorker
@project
=
Project
.
find
(
project_id
)
fetch_repository
(
@project
.
repository
,
@project
.
url_to_repo
)
# @current_user = @project.mirror_user || @project.creator
# Projects::UpdateMirrorService.new(@project, @current_user).execute
end
private
def
fetch_repository
(
repository
,
remote_url
)
repository
.
fetch_
upstream
(
remote_url
)
repository
.
fetch_
geo_mirror
(
remote_url
)
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