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
ff0508b5
Commit
ff0508b5
authored
Nov 15, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simulate cache specific concern for git_push_service in Geo
parent
e02f4eef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
app/services/geo/schedule_repo_update_service.rb
app/services/geo/schedule_repo_update_service.rb
+3
-1
app/workers/geo_repository_update_worker.rb
app/workers/geo_repository_update_worker.rb
+30
-4
No files found.
app/services/geo/schedule_repo_update_service.rb
View file @
ff0508b5
...
...
@@ -5,10 +5,12 @@ module Geo
def
initialize
(
params
)
@id
=
params
[
:project_id
]
@clone_url
=
params
[
:project
][
:git_ssh_url
]
@push_data
=
{
'type'
:
params
[
:object_kind
],
'before'
:
params
[
:before
],
'after'
:
params
[
:newref
],
'ref'
:
params
[
:ref
]
}
end
def
execute
GeoRepositoryUpdateWorker
.
perform_async
(
@id
,
@clone_url
)
GeoRepositoryUpdateWorker
.
perform_async
(
@id
,
@clone_url
,
@push_data
)
end
end
end
app/workers/geo_repository_update_worker.rb
View file @
ff0508b5
...
...
@@ -5,11 +5,12 @@ class GeoRepositoryUpdateWorker
attr_accessor
:project
def
perform
(
project_id
,
clone_url
)
def
perform
(
project_id
,
clone_url
,
push_data
)
@project
=
Project
.
find
(
project_id
)
@push_data
=
push_data
fetch_repository
(
clone_url
)
ProjectCacheWorker
.
perform_async
(
@project
.
id
)
process_hooks
end
private
...
...
@@ -17,8 +18,33 @@ class GeoRepositoryUpdateWorker
def
fetch_repository
(
remote_url
)
@project
.
create_repository
unless
@project
.
repository_exists?
@project
.
repository
.
after_create
if
@project
.
empty_repo?
@project
.
repository
.
fetch_geo_mirror
(
remote_url
)
@project
.
repository
.
after_import
end
def
process_hooks
if
@push_data
[
'type'
]
==
'push'
branch
=
Gitlab
::
Git
.
branch_ref?
(
@push_data
[
'ref'
])
process_push
(
branch
,
@push_data
[
'after'
])
end
end
def
process_push
(
branch
,
revision
)
@project
.
repository
.
after_push_commit
(
branch
,
revision
)
if
push_remove_branch?
@project
.
repository
.
after_remove_branch
elsif
push_to_new_branch?
@project
.
repository
.
after_create_branch
end
ProjectCacheWorker
.
perform_async
(
@project
.
id
)
end
def
push_remove_branch?
Gitlab
::
Git
.
branch_ref?
(
@push_data
[
'ref'
])
&&
Gitlab
::
Git
.
blank_ref?
(
@push_data
[
'after'
])
end
def
push_to_new_branch?
Gitlab
::
Git
.
branch_ref?
(
@push_data
[
'ref'
])
&&
Gitlab
::
Git
.
blank_ref?
(
@push_data
[
'before'
])
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