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
84e97e09
Commit
84e97e09
authored
Sep 03, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a repository updated event when updating the default branch
parent
fda055db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+7
-0
ee/app/services/geo/repository_sync_service.rb
ee/app/services/geo/repository_sync_service.rb
+2
-2
ee/spec/models/repository_spec.rb
ee/spec/models/repository_spec.rb
+20
-2
No files found.
ee/app/models/ee/repository.rb
View file @
84e97e09
...
...
@@ -78,6 +78,13 @@ module EE
log_geo_updated_event
end
override
:after_change_head
def
after_change_head
super
ensure
log_geo_updated_event
end
def
log_geo_updated_event
return
unless
::
Gitlab
::
Geo
.
primary?
...
...
ee/app/services/geo/repository_sync_service.rb
View file @
84e97e09
...
...
@@ -6,7 +6,7 @@ module Geo
def
sync_repository
fetch_repository
update_
default_branch
update_
root_ref
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.
...
...
@@ -46,7 +46,7 @@ module Geo
end
# Update the default branch querying the remote to determine its HEAD
def
update_
default_branch
def
update_
root_ref
root_ref
=
repository
.
find_remote_root_ref
(
GEO_REMOTE_NAME
)
project
.
change_head
(
root_ref
)
if
root_ref
.
present?
end
...
...
ee/spec/models/repository_spec.rb
View file @
84e97e09
...
...
@@ -3,8 +3,12 @@ require 'spec_helper'
describe
Repository
do
include
RepoHelpers
include
::
EE
::
GeoHelpers
TestBlob
=
Struct
.
new
(
:path
)
set
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
set
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
...
...
@@ -116,8 +120,6 @@ describe Repository do
end
describe
'#keep_around'
do
set
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
set
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:sha
)
{
sample_commit
.
id
}
context
'on a Geo primary'
do
...
...
@@ -174,4 +176,20 @@ describe Repository do
repository
.
code_owners_blob
end
end
describe
'#after_change_head'
do
it
'creates a RepositoryUpdatedEvent on a Geo primary'
do
stub_current_geo_node
(
primary_node
)
expect
{
repository
.
after_change_head
}
.
to
change
{
::
Geo
::
RepositoryUpdatedEvent
.
count
}.
by
(
1
)
end
it
'does not create a RepositoryUpdatedEvent on a Geo secondary'
do
stub_current_geo_node
(
secondary_node
)
expect
{
repository
.
after_change_head
}
.
not_to
change
{
::
Geo
::
RepositoryUpdatedEvent
.
count
}
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