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
9f06eb37
Commit
9f06eb37
authored
Jun 27, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Project#ensure_repository
parent
a014b5e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
app/models/project.rb
app/models/project.rb
+4
-0
app/services/geo/repository_sync_service.rb
app/services/geo/repository_sync_service.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+31
-0
No files found.
app/models/project.rb
View file @
9f06eb37
...
@@ -1080,6 +1080,10 @@ class Project < ActiveRecord::Base
...
@@ -1080,6 +1080,10 @@ class Project < ActiveRecord::Base
end
end
end
end
def
ensure_repository
create_repository
unless
repository_exists?
end
def
repository_exists?
def
repository_exists?
!!
repository
.
exists?
!!
repository
.
exists?
end
end
...
...
app/services/geo/repository_sync_service.rb
View file @
9f06eb37
...
@@ -65,7 +65,7 @@ module Geo
...
@@ -65,7 +65,7 @@ module Geo
finished_at
=
nil
finished_at
=
nil
begin
begin
project
.
create_repository
unless
project
.
repository_exists?
project
.
ensure_repository
project
.
repository
.
fetch_geo_mirror
(
ssh_url_to_repo
)
project
.
repository
.
fetch_geo_mirror
(
ssh_url_to_repo
)
finished_at
=
DateTime
.
now
finished_at
=
DateTime
.
now
...
...
spec/models/project_spec.rb
View file @
9f06eb37
...
@@ -1569,6 +1569,37 @@ describe Project, models: true do
...
@@ -1569,6 +1569,37 @@ describe Project, models: true do
end
end
end
end
describe
'#ensure_repository'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:shell
)
{
Gitlab
::
Shell
.
new
}
before
do
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
shell
)
end
it
'creates the repository if it not exist'
do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
false
)
allow
(
shell
).
to
receive
(
:add_repository
)
.
with
(
project
.
repository_storage_path
,
project
.
path_with_namespace
)
.
and_return
(
true
)
expect
(
project
).
to
receive
(
:create_repository
)
project
.
ensure_repository
end
it
'does not create the repository if it exists'
do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
true
)
expect
(
project
).
not_to
receive
(
:create_repository
)
project
.
ensure_repository
end
end
describe
'handling import URL'
do
describe
'handling import URL'
do
context
'when project is a mirror'
do
context
'when project is a mirror'
do
it
'returns the full URL'
do
it
'returns the full URL'
do
...
...
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