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
fce7464c
Commit
fce7464c
authored
Sep 20, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix delta size check to handle commit or nil objects
Closes #3446
parent
1a5db2eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
2 deletions
+33
-2
changelogs/unreleased-ee/sh-fix-delta-size-check.yml
changelogs/unreleased-ee/sh-fix-delta-size-check.yml
+5
-0
ee/lib/ee/gitlab/deltas.rb
ee/lib/ee/gitlab/deltas.rb
+7
-2
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+2
-0
spec/ee/spec/lib/ee/gitlab/deltas_spec.rb
spec/ee/spec/lib/ee/gitlab/deltas_spec.rb
+16
-0
spec/lib/gitlab/git/blob_spec.rb
spec/lib/gitlab/git/blob_spec.rb
+3
-0
No files found.
changelogs/unreleased-ee/sh-fix-delta-size-check.yml
0 → 100644
View file @
fce7464c
---
title
:
Fix delta size check to handle commit or nil objects
merge_request
:
author
:
type
:
fixed
ee/lib/ee/gitlab/deltas.rb
View file @
fce7464c
...
...
@@ -10,9 +10,14 @@ module EE
diff
=
tree_a
.
diff
(
tree_b
)
diff
.
each_delta
do
|
d
|
ne
w_file_size
=
d
.
deleted?
?
0
:
::
Gitlab
::
Git
::
Blob
.
raw
(
repo
,
d
.
new_file
[
:oid
]).
size
ne
xt
if
d
.
deleted?
size_of_deltas
+=
new_file_size
blob
=
::
Gitlab
::
Git
::
Blob
.
raw
(
repo
,
d
.
new_file
[
:oid
])
# It's possible the OID points to a commit or empty object
next
unless
blob
size_of_deltas
+=
blob
.
size
end
size_of_deltas
...
...
lib/gitlab/git/blob.rb
View file @
fce7464c
...
...
@@ -32,6 +32,8 @@ module Gitlab
else
blob
=
repository
.
lookup
(
sha
)
next
unless
blob
.
is_a?
(
Rugged
::
Blob
)
new
(
id:
blob
.
oid
,
size:
blob
.
size
,
...
...
spec/ee/spec/lib/ee/gitlab/deltas_spec.rb
0 → 100644
View file @
fce7464c
require
'spec_helper'
describe
EE
::
Gitlab
::
Deltas
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'.delta_size_check'
do
it
'returns a non-zero file size'
do
change
=
{
oldrev:
TestEnv
::
BRANCH_SHA
[
'feature'
],
newrev:
TestEnv
::
BRANCH_SHA
[
'master'
]
}
expect
(
described_class
.
delta_size_check
(
change
,
project
.
repository
)).
to
be
>
0
end
end
end
spec/lib/gitlab/git/blob_spec.rb
View file @
fce7464c
...
...
@@ -119,10 +119,13 @@ describe Gitlab::Git::Blob, seed_helper: true do
shared_examples
'finding blobs by ID'
do
let
(
:raw_blob
)
{
Gitlab
::
Git
::
Blob
.
raw
(
repository
,
SeedRepo
::
RubyBlob
::
ID
)
}
let
(
:bad_blob
)
{
Gitlab
::
Git
::
Blob
.
raw
(
repository
,
SeedRepo
::
BigCommit
::
ID
)
}
it
{
expect
(
raw_blob
.
id
).
to
eq
(
SeedRepo
::
RubyBlob
::
ID
)
}
it
{
expect
(
raw_blob
.
data
[
0
..
10
]).
to
eq
(
"require
\'
fi"
)
}
it
{
expect
(
raw_blob
.
size
).
to
eq
(
669
)
}
it
{
expect
(
raw_blob
.
truncated?
).
to
be_falsey
}
it
{
expect
(
bad_blob
).
to
be_nil
}
context
'large file'
do
it
'limits the size of a large file'
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