BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
049d4bae
Commit
049d4bae
authored
Jul 03, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sh-allow-force-repo-create' into 'master'
Make Project#ensure_repository force create a repo Closes gitlab-ee#2800 See merge request !12580
parents
65745f52
73f5b02b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
project.rb
app/models/project.rb
+10
-10
sh-allow-force-repo-create.yml
changelogs/unreleased/sh-allow-force-repo-create.yml
+4
-0
project_spec.rb
spec/models/project_spec.rb
+14
-1
No files found.
app/models/project.rb
View file @
049d4bae
...
...
@@ -1074,21 +1074,21 @@ class Project < ActiveRecord::Base
merge_requests
.
where
(
source_project_id:
self
.
id
)
end
def
create_repository
def
create_repository
(
force:
false
)
# Forked import is handled asynchronously
unless
forked?
if
gitlab_shell
.
add_repository
(
repository_storage_path
,
path_with_namespace
)
repository
.
after_create
tru
e
els
e
errors
.
add
(
:base
,
'Failed to create repository via gitlab-shell'
)
false
end
return
if
forked?
&&
!
force
if
gitlab_shell
.
add_repository
(
repository_storage_path
,
path_with_namespace
)
repository
.
after_creat
e
tru
e
else
errors
.
add
(
:base
,
'Failed to create repository via gitlab-shell'
)
false
end
end
def
ensure_repository
create_repository
unless
repository_exists?
create_repository
(
force:
true
)
unless
repository_exists?
end
def
repository_exists?
...
...
changelogs/unreleased/sh-allow-force-repo-create.yml
0 → 100644
View file @
049d4bae
---
title
:
Make Project#ensure_repository force create a repo
merge_request
:
author
:
spec/models/project_spec.rb
View file @
049d4bae
...
...
@@ -1346,7 +1346,7 @@ describe Project, models: true do
.
with
(
project
.
repository_storage_path
,
project
.
path_with_namespace
)
.
and_return
(
true
)
expect
(
project
).
to
receive
(
:create_repository
)
expect
(
project
).
to
receive
(
:create_repository
)
.
with
(
force:
true
)
project
.
ensure_repository
end
...
...
@@ -1359,6 +1359,19 @@ describe Project, models: true do
project
.
ensure_repository
end
it
'creates the repository if it is a fork'
do
expect
(
project
).
to
receive
(
:forked?
).
and_return
(
true
)
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
false
)
expect
(
shell
).
to
receive
(
:add_repository
)
.
with
(
project
.
repository_storage_path
,
project
.
path_with_namespace
)
.
and_return
(
true
)
project
.
ensure_repository
end
end
describe
'#user_can_push_to_empty_repo?'
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