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
93eba91d
Commit
93eba91d
authored
Dec 21, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Project#write_repository_config
parent
9d575acc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
41 deletions
+25
-41
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/project.rb
app/models/project.rb
+7
-8
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+1
-5
app/services/projects/hashed_storage/migrate_repository_service.rb
...ces/projects/hashed_storage/migrate_repository_service.rb
+2
-7
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+1
-4
lib/gitlab/bare_repository_import/importer.rb
lib/gitlab/bare_repository_import/importer.rb
+2
-5
spec/models/project_spec.rb
spec/models/project_spec.rb
+11
-11
No files found.
app/models/namespace.rb
View file @
93eba91d
...
...
@@ -272,7 +272,7 @@ class Namespace < ActiveRecord::Base
def
write_projects_full_path_config
all_projects
.
each
do
|
project
|
project
.
expires_full_path_cache
# we need to clear cache to validate renames correctly
project
.
write_repository_config
(
:fullpath
,
project
.
full_path
)
project
.
write_repository_config
end
end
end
app/models/project.rb
View file @
93eba91d
...
...
@@ -1420,10 +1420,7 @@ class Project < ActiveRecord::Base
end
def
after_rename_repo
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
write_repository_config
(
:fullpath
,
full_path
)
write_repository_config
path_before_change
=
previous_changes
[
'path'
].
first
...
...
@@ -1437,11 +1434,13 @@ class Project < ActiveRecord::Base
Gitlab
::
PagesTransfer
.
new
.
rename_project
(
path_before_change
,
self
.
path
,
namespace
.
full_path
)
end
def
write_repository_config
(
key
,
value
,
prefix: :gitlab
)
key
=
[
prefix
,
key
].
compact
.
join
(
'.'
)
repo
.
config
[
key
]
=
value
def
write_repository_config
(
gl_full_path:
full_path
)
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
repo
.
config
[
'gitlab.fullpath'
]
=
gl_full_path
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
Rails
.
logger
.
error
(
"Error writing
key
#{
key
}
to .git/config for project
#{
full_path
}
(
#{
id
}
):
#{
e
.
message
}
."
)
Rails
.
logger
.
error
(
"Error writing to .git/config for project
#{
full_path
}
(
#{
id
}
):
#{
e
.
message
}
."
)
nil
end
...
...
app/services/projects/create_service.rb
View file @
93eba91d
...
...
@@ -88,11 +88,7 @@ module Projects
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
unless
@project
.
gitlab_project_import?
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
@project
.
write_repository_config
(
:fullpath
,
@project
.
full_path
)
@project
.
write_repository_config
@project
.
create_wiki
unless
skip_wiki?
create_services_from_active_templates
(
@project
)
...
...
app/services/projects/hashed_storage/migrate_repository_service.rb
View file @
93eba91d
...
...
@@ -30,6 +30,8 @@ module Projects
unless
result
rollback_folder_move
project
.
storage_version
=
nil
else
project
.
write_repository_config
end
project
.
repository_read_only
=
false
...
...
@@ -39,13 +41,6 @@ module Projects
yield
end
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
if
result
project
.
write_repository_config
(
:fullpath
,
project
.
full_path
)
end
result
end
...
...
app/services/projects/transfer_service.rb
View file @
93eba91d
...
...
@@ -101,10 +101,7 @@ module Projects
end
def
write_repository_config
(
full_path
)
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
project
.
write_repository_config
(
:fullpath
,
full_path
)
project
.
write_repository_config
(
:gl_fullpath
,
full_path
)
end
def
refresh_permissions
...
...
lib/gitlab/bare_repository_import/importer.rb
View file @
93eba91d
...
...
@@ -20,7 +20,7 @@ module Gitlab
next
end
log
"Processing
#{
repo_path
}
->
#{
bare_repo
.
project_full_path
}
"
.
color
(
:yellow
)
log
"Processing
#{
repo_path
}
"
.
color
(
:yellow
)
new
(
user
,
bare_repo
).
create_project_if_needed
end
...
...
@@ -62,10 +62,7 @@ module Gitlab
if
project
.
persisted?
&&
mv_repo
(
project
)
log
" * Created
#{
project
.
name
}
(
#{
project_full_path
}
)"
.
color
(
:green
)
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
project
.
write_repository_config
(
:fullpath
,
project
.
full_path
)
project
.
write_repository_config
ProjectCacheWorker
.
perform_async
(
project
.
id
)
else
...
...
spec/models/project_spec.rb
View file @
93eba91d
...
...
@@ -2630,9 +2630,9 @@ describe Project do
it
'updates project full path in .git/config'
do
allow
(
project_storage
).
to
receive
(
:rename_repo
).
and_return
(
true
)
expect
(
project
).
to
receive
(
:write_repository_config
).
with
(
:fullpath
,
project
.
full_path
)
project
.
rename_repo
expect
(
project
.
repo
.
config
[
'gitlab.fullpath'
]).
to
eq
(
project
.
full_path
)
end
end
...
...
@@ -2678,12 +2678,10 @@ describe Project do
context
'hashed storage'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
skip_disk_validation:
true
)
}
let
(
:gitlab_shell
)
{
Gitlab
::
Shell
.
new
}
let
(
:hash
)
{
'6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
}
let
(
:hash
)
{
Digest
::
SHA2
.
hexdigest
(
project
.
id
.
to_s
)
}
before
do
stub_application_setting
(
hashed_storage_enabled:
true
)
allow
(
Digest
::
SHA2
).
to
receive
(
:hexdigest
)
{
hash
}
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
end
describe
'#legacy_storage?'
do
...
...
@@ -2706,13 +2704,13 @@ describe Project do
describe
'#base_dir'
do
it
'returns base_dir based on hash of project id'
do
expect
(
project
.
base_dir
).
to
eq
(
'@hashed/6b/86'
)
expect
(
project
.
base_dir
).
to
eq
(
"@hashed/
#{
hash
[
0
..
1
]
}
/
#{
hash
[
2
..
3
]
}
"
)
end
end
describe
'#disk_path'
do
it
'returns disk_path based on hash of project id'
do
hashed_path
=
'@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
hashed_path
=
"@hashed/
#{
hash
[
0
..
1
]
}
/
#{
hash
[
2
..
3
]
}
/
#{
hash
}
"
expect
(
project
.
disk_path
).
to
eq
(
hashed_path
)
end
...
...
@@ -2720,7 +2718,9 @@ describe Project do
describe
'#ensure_storage_path_exists'
do
it
'delegates to gitlab_shell to ensure namespace is created'
do
expect
(
gitlab_shell
).
to
receive
(
:add_namespace
).
with
(
project
.
repository_storage_path
,
'@hashed/6b/86'
)
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
expect
(
gitlab_shell
).
to
receive
(
:add_namespace
).
with
(
project
.
repository_storage_path
,
"@hashed/
#{
hash
[
0
..
1
]
}
/
#{
hash
[
2
..
3
]
}
"
)
project
.
ensure_storage_path_exists
end
...
...
@@ -2780,7 +2780,7 @@ describe Project do
end
context
'when not rolled out'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
storage_version:
1
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
storage_version:
1
,
skip_disk_validation:
true
)
}
it
'moves pages folder to new location'
do
expect_any_instance_of
(
Gitlab
::
UploadsTransfer
).
to
receive
(
:rename_project
)
...
...
@@ -2791,9 +2791,9 @@ describe Project do
end
it
'updates project full path in .git/config'
do
expect
(
project
).
to
receive
(
:write_repository_config
).
with
(
:fullpath
,
project
.
full_path
)
project
.
rename_repo
expect
(
project
.
repo
.
config
[
'gitlab.fullpath'
]).
to
eq
(
project
.
full_path
)
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