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
9673458e
Commit
9673458e
authored
Mar 14, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-create-repo-opt-out' into 'master'
Move CreateRepository to OPT_OUT for Gitaly See merge request gitlab-org/gitlab-ce!17740
parents
937a99a4
7d02292a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
31 additions
and
30 deletions
+31
-30
project.rb
app/models/project.rb
+1
-1
project_wiki.rb
app/models/project_wiki.rb
+1
-1
shell.rb
lib/gitlab/shell.rb
+7
-6
shell.rake
lib/tasks/gitlab/shell.rake
+1
-1
repository_spec.rb
spec/lib/gitlab/bare_repository_import/repository_spec.rb
+1
-1
repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+1
-1
shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+8
-8
project_spec.rb
spec/models/project_spec.rb
+5
-5
project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+1
-1
create_service_spec.rb
spec/services/projects/create_service_spec.rb
+2
-2
fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+1
-1
transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+1
-1
update_service_spec.rb
spec/services/projects/update_service_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
9673458e
...
...
@@ -1083,7 +1083,7 @@ class Project < ActiveRecord::Base
# Forked import is handled asynchronously
return
if
forked?
&&
!
force
if
gitlab_shell
.
add
_repository
(
repository_storage
,
disk_path
)
if
gitlab_shell
.
create
_repository
(
repository_storage
,
disk_path
)
repository
.
after_create
true
else
...
...
app/models/project_wiki.rb
View file @
9673458e
...
...
@@ -169,7 +169,7 @@ class ProjectWiki
private
def
create_repo!
(
raw_repository
)
gitlab_shell
.
add
_repository
(
project
.
repository_storage
,
disk_path
)
gitlab_shell
.
create
_repository
(
project
.
repository_storage
,
disk_path
)
raise
CouldNotCreateWikiError
unless
raw_repository
.
exists?
...
...
lib/gitlab/shell.rb
View file @
9673458e
...
...
@@ -69,13 +69,14 @@ module Gitlab
# name - project disk path
#
# Ex.
#
add
_repository("/path/to/storage", "gitlab/gitlab-ci")
#
create
_repository("/path/to/storage", "gitlab/gitlab-ci")
#
def
add
_repository
(
storage
,
name
)
def
create
_repository
(
storage
,
name
)
relative_path
=
name
.
dup
relative_path
<<
'.git'
unless
relative_path
.
end_with?
(
'.git'
)
gitaly_migrate
(
:create_repository
)
do
|
is_enabled
|
gitaly_migrate
(
:create_repository
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_OUT
)
do
|
is_enabled
|
if
is_enabled
repository
=
Gitlab
::
Git
::
Repository
.
new
(
storage
,
relative_path
,
''
)
repository
.
gitaly_repository_client
.
create_repository
...
...
@@ -85,7 +86,7 @@ module Gitlab
Gitlab
::
Git
::
Repository
.
create
(
repo_path
,
bare:
true
,
symlink_hooks_to:
gitlab_shell_hooks_path
)
end
end
rescue
=>
err
rescue
=>
err
# Once the Rugged codes gets removes this can be improved
Rails
.
logger
.
error
(
"Failed to add repository
#{
storage
}
/
#{
name
}
:
#{
err
}
"
)
false
end
...
...
@@ -487,8 +488,8 @@ module Gitlab
Gitlab
.
config
.
gitlab_shell
.
git_timeout
end
def
gitaly_migrate
(
method
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
&
block
)
def
gitaly_migrate
(
method
,
status:
Gitlab
::
GitalyClient
::
MigrationStatus
::
OPT_IN
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
status:
status
,
&
block
)
rescue
GRPC
::
NotFound
,
GRPC
::
BadStatus
=>
e
# Old Popen code returns [Error, output] to the caller, so we
# need to do the same here...
...
...
lib/tasks/gitlab/shell.rake
View file @
9673458e
...
...
@@ -69,7 +69,7 @@ namespace :gitlab do
if
File
.
exist?
(
path_to_repo
)
print
'-'
else
if
Gitlab
::
Shell
.
new
.
add
_repository
(
project
.
repository_storage
,
if
Gitlab
::
Shell
.
new
.
create
_repository
(
project
.
repository_storage
,
project
.
disk_path
)
print
'.'
else
...
...
spec/lib/gitlab/bare_repository_import/repository_spec.rb
View file @
9673458e
...
...
@@ -61,7 +61,7 @@ describe ::Gitlab::BareRepositoryImport::Repository do
let
(
:wiki_path
)
{
File
.
join
(
root_path
,
"
#{
hashed_path
}
.wiki.git"
)
}
before
do
gitlab_shell
.
add
_repository
(
repository_storage
,
hashed_path
)
gitlab_shell
.
create
_repository
(
repository_storage
,
hashed_path
)
repository
=
Rugged
::
Repository
.
new
(
repo_path
)
repository
.
config
[
'gitlab.fullpath'
]
=
'to/repo'
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
9673458e
...
...
@@ -681,7 +681,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
subject
{
new_repository
.
fetch_repository_as_mirror
(
repository
)
}
before
do
Gitlab
::
Shell
.
new
.
add
_repository
(
'default'
,
'my_project'
)
Gitlab
::
Shell
.
new
.
create
_repository
(
'default'
,
'my_project'
)
end
after
do
...
...
spec/lib/gitlab/shell_spec.rb
View file @
9673458e
...
...
@@ -20,7 +20,7 @@ describe Gitlab::Shell do
it
{
is_expected
.
to
respond_to
:add_key
}
it
{
is_expected
.
to
respond_to
:remove_key
}
it
{
is_expected
.
to
respond_to
:
add
_repository
}
it
{
is_expected
.
to
respond_to
:
create
_repository
}
it
{
is_expected
.
to
respond_to
:remove_repository
}
it
{
is_expected
.
to
respond_to
:fork_repository
}
...
...
@@ -402,8 +402,8 @@ describe Gitlab::Shell do
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:git_timeout
).
and_return
(
800
)
end
describe
'#
add
_repository'
do
shared_examples
'#
add
_repository'
do
describe
'#
create
_repository'
do
shared_examples
'#
create
_repository'
do
let
(
:repository_storage
)
{
'default'
}
let
(
:repository_storage_path
)
{
Gitlab
.
config
.
repositories
.
storages
[
repository_storage
][
'path'
]
}
let
(
:repo_name
)
{
'project/path'
}
...
...
@@ -414,7 +414,7 @@ describe Gitlab::Shell do
end
it
'creates a repository'
do
expect
(
gitlab_shell
.
add
_repository
(
repository_storage
,
repo_name
)).
to
be_truthy
expect
(
gitlab_shell
.
create
_repository
(
repository_storage
,
repo_name
)).
to
be_truthy
expect
(
File
.
stat
(
created_path
).
mode
&
0
o777
).
to
eq
(
0
o770
)
...
...
@@ -426,19 +426,19 @@ describe Gitlab::Shell do
it
'returns false when the command fails'
do
FileUtils
.
mkdir_p
(
File
.
dirname
(
created_path
))
# This file will block the creation of the repo's .git directory. That
# should cause #
add
_repository to fail.
# should cause #
create
_repository to fail.
FileUtils
.
touch
(
created_path
)
expect
(
gitlab_shell
.
add
_repository
(
repository_storage
,
repo_name
)).
to
be_falsy
expect
(
gitlab_shell
.
create
_repository
(
repository_storage
,
repo_name
)).
to
be_falsy
end
end
context
'with gitaly'
do
it_behaves_like
'#
add
_repository'
it_behaves_like
'#
create
_repository'
end
context
'without gitaly'
,
:skip_gitaly_mock
do
it_behaves_like
'#
add
_repository'
it_behaves_like
'#
create
_repository'
end
end
...
...
spec/models/project_spec.rb
View file @
9673458e
...
...
@@ -1378,7 +1378,7 @@ describe Project do
context
'using a regular repository'
do
it
'creates the repository'
do
expect
(
shell
).
to
receive
(
:
add
_repository
)
expect
(
shell
).
to
receive
(
:
create
_repository
)
.
with
(
project
.
repository_storage
,
project
.
disk_path
)
.
and_return
(
true
)
...
...
@@ -1388,7 +1388,7 @@ describe Project do
end
it
'adds an error if the repository could not be created'
do
expect
(
shell
).
to
receive
(
:
add
_repository
)
expect
(
shell
).
to
receive
(
:
create
_repository
)
.
with
(
project
.
repository_storage
,
project
.
disk_path
)
.
and_return
(
false
)
...
...
@@ -1402,7 +1402,7 @@ describe Project do
context
'using a forked repository'
do
it
'does nothing'
do
expect
(
project
).
to
receive
(
:forked?
).
and_return
(
true
)
expect
(
shell
).
not_to
receive
(
:
add
_repository
)
expect
(
shell
).
not_to
receive
(
:
create
_repository
)
project
.
create_repository
end
...
...
@@ -1421,7 +1421,7 @@ describe Project do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
false
)
allow
(
shell
).
to
receive
(
:
add
_repository
)
allow
(
shell
).
to
receive
(
:
create
_repository
)
.
with
(
project
.
repository_storage_path
,
project
.
disk_path
)
.
and_return
(
true
)
...
...
@@ -1445,7 +1445,7 @@ describe Project do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
false
)
expect
(
shell
).
to
receive
(
:
add
_repository
)
expect
(
shell
).
to
receive
(
:
create
_repository
)
.
with
(
project
.
repository_storage
,
project
.
disk_path
)
.
and_return
(
true
)
...
...
spec/models/project_wiki_spec.rb
View file @
9673458e
...
...
@@ -74,7 +74,7 @@ describe ProjectWiki do
# Create a fresh project which will not have a wiki
project_wiki
=
described_class
.
new
(
create
(
:project
),
user
)
gitlab_shell
=
double
(
:gitlab_shell
)
allow
(
gitlab_shell
).
to
receive
(
:
add
_repository
)
allow
(
gitlab_shell
).
to
receive
(
:
create
_repository
)
allow
(
project_wiki
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
expect
{
project_wiki
.
send
(
:wiki
)
}.
to
raise_exception
(
ProjectWiki
::
CouldNotCreateWikiError
)
...
...
spec/services/projects/create_service_spec.rb
View file @
9673458e
...
...
@@ -164,7 +164,7 @@ describe Projects::CreateService, '#execute' do
context
'with legacy storage'
do
before
do
gitlab_shell
.
add
_repository
(
repository_storage
,
"
#{
user
.
namespace
.
full_path
}
/existing"
)
gitlab_shell
.
create
_repository
(
repository_storage
,
"
#{
user
.
namespace
.
full_path
}
/existing"
)
end
after
do
...
...
@@ -200,7 +200,7 @@ describe Projects::CreateService, '#execute' do
end
before
do
gitlab_shell
.
add
_repository
(
repository_storage
,
hashed_path
)
gitlab_shell
.
create
_repository
(
repository_storage
,
hashed_path
)
end
after
do
...
...
spec/services/projects/fork_service_spec.rb
View file @
9673458e
...
...
@@ -108,7 +108,7 @@ describe Projects::ForkService do
let
(
:repository_storage_path
)
{
Gitlab
.
config
.
repositories
.
storages
[
repository_storage
][
'path'
]
}
before
do
gitlab_shell
.
add
_repository
(
repository_storage
,
"
#{
@to_user
.
namespace
.
full_path
}
/
#{
@from_project
.
path
}
"
)
gitlab_shell
.
create
_repository
(
repository_storage
,
"
#{
@to_user
.
namespace
.
full_path
}
/
#{
@from_project
.
path
}
"
)
end
after
do
...
...
spec/services/projects/transfer_service_spec.rb
View file @
9673458e
...
...
@@ -151,7 +151,7 @@ describe Projects::TransferService do
before
do
group
.
add_owner
(
user
)
unless
gitlab_shell
.
add
_repository
(
repository_storage
,
"
#{
group
.
full_path
}
/
#{
project
.
path
}
"
)
unless
gitlab_shell
.
create
_repository
(
repository_storage
,
"
#{
group
.
full_path
}
/
#{
project
.
path
}
"
)
raise
'failed to add repository'
end
...
...
spec/services/projects/update_service_spec.rb
View file @
9673458e
...
...
@@ -196,7 +196,7 @@ describe Projects::UpdateService do
let
(
:project
)
{
create
(
:project
,
:legacy_storage
,
:repository
,
creator:
user
,
namespace:
user
.
namespace
)
}
before
do
gitlab_shell
.
add
_repository
(
repository_storage
,
"
#{
user
.
namespace
.
full_path
}
/existing"
)
gitlab_shell
.
create
_repository
(
repository_storage
,
"
#{
user
.
namespace
.
full_path
}
/existing"
)
end
after
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