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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ebd51744
Commit
ebd51744
authored
Nov 08, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle forks in Gitlab::Checks::LfsIntegrity
parent
78ea074f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
19 deletions
+57
-19
app/controllers/concerns/lfs_request.rb
app/controllers/concerns/lfs_request.rb
+1
-9
app/models/lfs_object.rb
app/models/lfs_object.rb
+1
-9
app/models/project.rb
app/models/project.rb
+12
-0
lib/gitlab/checks/lfs_integrity.rb
lib/gitlab/checks/lfs_integrity.rb
+4
-1
spec/lib/gitlab/checks/lfs_integrity_spec.rb
spec/lib/gitlab/checks/lfs_integrity_spec.rb
+21
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+18
-0
No files found.
app/controllers/concerns/lfs_request.rb
View file @
ebd51744
...
...
@@ -91,15 +91,7 @@ module LfsRequest
end
def
storage_project
@storage_project
||=
begin
result
=
project
# TODO: Make this go to the fork_network root immeadiatly
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
result
=
result
.
fork_source
while
result
.
forked?
result
end
@storage_project
||=
project
.
lfs_storage_project
end
def
objects
...
...
app/models/lfs_object.rb
View file @
ebd51744
...
...
@@ -6,16 +6,8 @@ class LfsObject < ActiveRecord::Base
mount_uploader
:file
,
LfsObjectUploader
def
storage_project
(
project
)
if
project
&&
project
.
forked?
storage_project
(
project
.
forked_from_project
)
else
project
end
end
def
project_allowed_access?
(
project
)
projects
.
exists?
(
storage_project
(
project
)
.
id
)
projects
.
exists?
(
project
.
lfs_storage_project
.
id
)
end
def
self
.
destroy_unreferenced
...
...
app/models/project.rb
View file @
ebd51744
...
...
@@ -1042,6 +1042,18 @@ class Project < ActiveRecord::Base
forked_from_project
||
fork_network
&
.
root_project
end
def
lfs_storage_project
@lfs_storage_project
||=
begin
result
=
self
# TODO: Make this go to the fork_network root immeadiatly
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
result
=
result
.
fork_source
while
result
&
.
forked?
result
||
self
end
end
def
personal?
!
group
end
...
...
lib/gitlab/checks/lfs_integrity.rb
View file @
ebd51744
...
...
@@ -15,7 +15,10 @@ module Gitlab
return
false
unless
new_lfs_pointers
.
present?
existing_count
=
@project
.
lfs_objects
.
where
(
oid:
new_lfs_pointers
.
map
(
&
:lfs_oid
)).
count
existing_count
=
@project
.
lfs_storage_project
.
lfs_objects
.
where
(
oid:
new_lfs_pointers
.
map
(
&
:lfs_oid
))
.
count
existing_count
!=
new_lfs_pointers
.
count
end
...
...
spec/lib/gitlab/checks/lfs_integrity_spec.rb
View file @
ebd51744
require
'spec_helper'
describe
Gitlab
::
Checks
::
LfsIntegrity
do
include
ProjectForksHelper
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:newrev
)
{
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
}
...
...
@@ -49,5 +50,25 @@ describe Gitlab::Checks::LfsIntegrity do
expect
(
subject
.
objects_missing?
).
to
be_falsey
end
end
context
'for forked project'
do
let
(
:parent_project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
fork_project
(
parent_project
,
nil
,
repository:
true
)
}
before
do
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
end
it
'is true parent project is missing LFS objects'
do
expect
(
subject
.
objects_missing?
).
to
be_truthy
end
it
'is false parent project already conatins LFS objects for the fork'
do
lfs_object
=
create
(
:lfs_object
,
oid:
blob_object
.
lfs_oid
)
create
(
:lfs_objects_project
,
project:
parent_project
,
lfs_object:
lfs_object
)
expect
(
subject
.
objects_missing?
).
to
be_falsey
end
end
end
end
spec/models/project_spec.rb
View file @
ebd51744
...
...
@@ -1943,6 +1943,24 @@ describe Project do
expect
(
second_fork
.
fork_source
).
to
eq
(
project
)
end
end
describe
'#lfs_storage_project'
do
it
'returns self for non-forks'
do
expect
(
project
.
lfs_storage_project
).
to
eq
project
end
it
'returns the fork network root for forks'
do
second_fork
=
fork_project
(
forked_project
)
expect
(
second_fork
.
lfs_storage_project
).
to
eq
project
end
it
'returns self when fork_source is nil'
do
expect
(
forked_project
).
to
receive
(
:fork_source
).
and_return
(
nil
)
expect
(
forked_project
.
lfs_storage_project
).
to
eq
forked_project
end
end
end
describe
'#pushes_since_gc'
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