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
fda055db
Commit
fda055db
authored
Sep 03, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Synchronize the default branch in secondary nodes
parent
1f93e85a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
9 deletions
+22
-9
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+1
-1
ee/app/services/geo/repository_sync_service.rb
ee/app/services/geo/repository_sync_service.rb
+5
-8
ee/spec/services/geo/repository_sync_service_spec.rb
ee/spec/services/geo/repository_sync_service_spec.rb
+16
-0
No files found.
ee/app/models/ee/repository.rb
View file @
fda055db
...
...
@@ -10,7 +10,7 @@ module EE
MIRROR_REMOTE
=
"upstream"
.
freeze
included
do
delegate
:checksum
,
to: :raw_repository
delegate
:checksum
,
:find_remote_root_ref
,
to: :raw_repository
end
# Transiently sets a configuration variable
...
...
ee/app/services/geo/repository_sync_service.rb
View file @
fda055db
...
...
@@ -6,9 +6,7 @@ module Geo
def
sync_repository
fetch_repository
update_gitattributes
update_default_branch
mark_sync_as_successful
rescue
Gitlab
::
Shell
::
Error
=>
e
# In some cases repository does not exist, the only way to know about this is to parse the error text.
...
...
@@ -47,11 +45,10 @@ module Geo
project
.
ensure_repository
end
# Update info/attributes file using the contents of .gitattributes file from the default branch
def
update_gitattributes
return
if
project
.
default_branch
.
nil?
repository
.
copy_gitattributes
(
project
.
default_branch
)
# Update the default branch querying the remote to determine its HEAD
def
update_default_branch
root_ref
=
repository
.
find_remote_root_ref
(
GEO_REMOTE_NAME
)
project
.
change_head
(
root_ref
)
if
root_ref
.
present?
end
def
schedule_repack
...
...
ee/spec/services/geo/repository_sync_service_spec.rb
View file @
fda055db
...
...
@@ -31,6 +31,11 @@ describe Geo::RepositorySyncService do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_as_mirror
)
.
and_return
(
true
)
allow_any_instance_of
(
Repository
)
.
to
receive
(
:find_remote_root_ref
)
.
with
(
'geo'
)
.
and_return
(
'master'
)
end
it
'fetches project repository with JWT credentials'
do
...
...
@@ -215,6 +220,17 @@ describe Geo::RepositorySyncService do
subject
.
execute
end
it
'updates the default branch'
do
allow
(
project
.
repository
)
.
to
receive
(
:find_remote_root_ref
)
.
with
(
'geo'
)
.
and_return
(
'development'
)
expect
(
project
).
to
receive
(
:change_head
).
with
(
'development'
).
once
subject
.
execute
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