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
440604ad
Unverified
Commit
440604ad
authored
Oct 28, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor storage path extraction from full repo path
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
3095ac0c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
repository.rb
app/models/repository.rb
+14
-0
internal.rb
lib/api/internal.rb
+1
-6
repository_spec.rb
spec/models/repository_spec.rb
+10
-0
No files found.
app/models/repository.rb
View file @
440604ad
...
...
@@ -11,6 +11,20 @@ class Repository
attr_accessor
:path_with_namespace
,
:project
def
self
.
storages
Gitlab
.
config
.
repositories
.
storages
end
def
self
.
remove_storage_from_path
(
repo_path
)
storages
.
find
do
|
_
,
storage_path
|
if
repo_path
.
start_with?
(
storage_path
)
return
repo_path
.
sub
(
storage_path
,
''
)
end
end
repo_path
end
def
initialize
(
path_with_namespace
,
project
)
@path_with_namespace
=
path_with_namespace
@project
=
project
...
...
lib/api/internal.rb
View file @
440604ad
...
...
@@ -20,12 +20,7 @@ module API
def
project_path
@project_path
||=
begin
project_path
=
params
[
:project
].
sub
(
/\.git\z/
,
''
)
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
_
,
storage_path
|
project_path
.
sub!
(
storage_path
,
''
)
end
project_path
Repository
.
remove_storage_from_path
(
project_path
)
end
end
...
...
spec/models/repository_spec.rb
View file @
440604ad
...
...
@@ -1472,4 +1472,14 @@ describe Repository, models: true do
end
.
to
raise_error
(
Repository
::
CommitError
)
end
end
describe
'#remove_storage_from_path'
do
let
(
:storage_path
)
{
project
.
repository_storage_path
}
let
(
:project_path
)
{
project
.
path_with_namespace
}
let
(
:full_path
)
{
File
.
join
(
storage_path
,
project_path
)
}
it
{
expect
(
Repository
.
remove_storage_from_path
(
full_path
)).
to
eq
(
project_path
)
}
it
{
expect
(
Repository
.
remove_storage_from_path
(
project_path
)).
to
eq
(
project_path
)
}
it
{
expect
(
Repository
.
remove_storage_from_path
(
storage_path
)).
to
eq
(
''
)
}
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