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
201802f7
Commit
201802f7
authored
Jul 03, 2018
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove more feature flags
parent
d4a4f1ed
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
108 deletions
+65
-108
lib/gitlab/git/commit_stats.rb
lib/gitlab/git/commit_stats.rb
+2
-14
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+4
-21
lib/gitlab/git/tree.rb
lib/gitlab/git/tree.rb
+2
-8
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+2
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+55
-65
No files found.
lib/gitlab/git/commit_stats.rb
View file @
201802f7
# Gitaly note: JV: 1 RPC, migration in progress.
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes
# in a commit.
module
Gitlab
...
...
@@ -16,12 +14,8 @@ module Gitlab
@deletions
=
0
@total
=
0
repo
.
gitaly_migrate
(
:commit_stats
)
do
|
is_enabled
|
if
is_enabled
gitaly_stats
(
repo
,
commit
)
else
rugged_stats
(
commit
)
end
repo
.
wrapped_gitaly_errors
do
gitaly_stats
(
repo
,
commit
)
end
end
...
...
@@ -31,12 +25,6 @@ module Gitlab
@deletions
=
stats
.
deletions
@total
=
@additions
+
@deletions
end
def
rugged_stats
(
commit
)
diff
=
commit
.
rugged_diff_from_parent
_files_changed
,
@additions
,
@deletions
=
diff
.
stat
@total
=
@additions
+
@deletions
end
end
end
end
lib/gitlab/git/repository.rb
View file @
201802f7
...
...
@@ -251,7 +251,6 @@ module Gitlab
# Returns an Array of Tags
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/390
def
tags
wrapped_gitaly_errors
do
gitaly_ref_client
.
tags
...
...
@@ -602,17 +601,9 @@ module Gitlab
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/329
def
submodule_url_for
(
ref
,
path
)
Gitlab
::
GitalyClient
.
migrate
(
:submodule_url_for
)
do
|
is_enabled
|
if
is_enabled
gitaly_submodule_url_for
(
ref
,
path
)
else
if
submodules
(
ref
).
any?
submodule
=
submodules
(
ref
)[
path
]
submodule
[
'url'
]
if
submodule
end
end
wrapped_gitaly_errors
do
gitaly_submodule_url_for
(
ref
,
path
)
end
end
...
...
@@ -837,22 +828,14 @@ module Gitlab
# Ex.
# repo.ls_files('master')
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/327
def
ls_files
(
ref
)
gitaly_commit_client
.
ls_files
(
ref
)
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/328
def
copy_gitattributes
(
ref
)
Gitlab
::
GitalyClient
.
migrate
(
:apply_gitattributes
)
do
|
is_enabled
|
if
is_enabled
gitaly_copy_gitattributes
(
ref
)
else
rugged_copy_gitattributes
(
ref
)
end
wrapped_gitaly_errors
do
gitaly_repository_client
.
apply_gitattributes
(
ref
)
end
rescue
GRPC
::
InvalidArgument
raise
InvalidRef
end
def
info_attributes
...
...
lib/gitlab/git/tree.rb
View file @
201802f7
# Gitaly note: JV: needs 1 RPC, migration is in progress.
module
Gitlab
module
Git
class
Tree
...
...
@@ -17,12 +15,8 @@ module Gitlab
def
where
(
repository
,
sha
,
path
=
nil
,
recursive
=
false
)
path
=
nil
if
path
==
''
||
path
==
'/'
Gitlab
::
GitalyClient
.
migrate
(
:tree_entries
)
do
|
is_enabled
|
if
is_enabled
repository
.
gitaly_commit_client
.
tree_entries
(
repository
,
sha
,
path
,
recursive
)
else
tree_entries_from_rugged
(
repository
,
sha
,
path
,
recursive
)
end
repository
.
wrapped_gitaly_errors
do
repository
.
gitaly_commit_client
.
tree_entries
(
repository
,
sha
,
path
,
recursive
)
end
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
201802f7
...
...
@@ -48,6 +48,8 @@ module Gitlab
def
apply_gitattributes
(
revision
)
request
=
Gitaly
::
ApplyGitattributesRequest
.
new
(
repository:
@gitaly_repo
,
revision:
encode_binary
(
revision
))
GitalyClient
.
call
(
@storage
,
:repository_service
,
:apply_gitattributes
,
request
)
rescue
GRPC
::
InvalidArgument
=>
ex
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
,
ex
end
def
info_attributes
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
201802f7
...
...
@@ -1402,94 +1402,84 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
describe
"#copy_gitattributes"
do
shared_examples
'applying git attributes'
do
let
(
:attributes_path
)
{
File
.
join
(
SEED_STORAGE_PATH
,
TEST_REPO_PATH
,
'info/attributes'
)
}
let
(
:attributes_path
)
{
File
.
join
(
SEED_STORAGE_PATH
,
TEST_REPO_PATH
,
'info/attributes'
)
}
after
do
FileUtils
.
rm_rf
(
attributes_path
)
if
Dir
.
exist?
(
attributes_path
)
end
it
"raises an error with invalid ref"
do
expect
{
repository
.
copy_gitattributes
(
"invalid"
)
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
InvalidRef
)
end
context
'when forcing encoding issues'
do
let
(
:branch_name
)
{
"ʕ•ᴥ•ʔ"
}
after
do
FileUtils
.
rm_rf
(
attributes_path
)
if
Dir
.
exist?
(
attributes_path
)
end
before
do
repository
.
create_branch
(
branch_name
,
"master"
)
end
it
"raises an error with invalid ref"
do
expect
{
repository
.
copy_gitattributes
(
"invalid"
)
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
InvalidRef
)
end
after
do
repository
.
rm_branch
(
branch_name
,
user:
build
(
:admin
))
end
context
'when forcing encoding issues'
do
let
(
:branch_name
)
{
"ʕ•ᴥ•ʔ"
}
it
"doesn't raise with a valid unicode ref"
do
expect
{
repository
.
copy_gitattributes
(
branch_name
)
}.
not_to
raise_error
before
do
repository
.
create_branch
(
branch_name
,
"master"
)
end
repository
end
after
do
repository
.
rm_branch
(
branch_name
,
user:
build
(
:admin
))
end
context
"with no .gitattrbutes"
do
before
do
repository
.
copy_gitattributes
(
"master"
)
end
it
"doesn't raise with a valid unicode ref"
do
expect
{
repository
.
copy_gitattributes
(
branch_name
)
}.
not_to
raise_error
it
"does not have an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_falsey
end
repository
end
end
context
"with
.gitattrbutes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes
"
)
end
context
"with no
.gitattrbutes"
do
before
do
repository
.
copy_gitattributes
(
"master
"
)
end
it
"has an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_truthy
end
it
"does not have an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_falsey
end
end
it
"has the same content in info/attributes as .gitattributes"
do
contents
=
File
.
open
(
attributes_path
,
"rb"
)
{
|
f
|
f
.
read
}
expect
(
contents
).
to
eq
(
"*.md binary
\n
"
)
end
context
"with .gitattrbutes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes"
)
end
context
"with updated .gitattrbutes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes"
)
repository
.
copy_gitattributes
(
"gitattributes-updated"
)
end
it
"has an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_truthy
end
it
"has an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_truthy
end
it
"has the same content in info/attributes as .gitattributes"
do
contents
=
File
.
open
(
attributes_path
,
"rb"
)
{
|
f
|
f
.
read
}
expect
(
contents
).
to
eq
(
"*.md binary
\n
"
)
end
end
it
"has the updated content in info/attri
butes"
do
contents
=
File
.
read
(
attributes_path
)
expect
(
contents
).
to
eq
(
"*.txt binary
\n
"
)
end
context
"with updated .gitattr
butes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes
"
)
repository
.
copy_gitattributes
(
"gitattributes-updated"
)
end
context
"with no .gitattrbutes in HEAD but with previous info/attributes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes"
)
repository
.
copy_gitattributes
(
"master"
)
end
it
"has an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_truthy
end
it
"does not have a
n info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_falsey
e
nd
it
"has the updated content i
n info/attributes"
do
contents
=
File
.
read
(
attributes_path
)
e
xpect
(
contents
).
to
eq
(
"*.txt binary
\n
"
)
end
end
context
'when gitaly is enabled'
do
it_behaves_like
'applying git attributes'
end
context
"with no .gitattrbutes in HEAD but with previous info/attributes"
do
before
do
repository
.
copy_gitattributes
(
"gitattributes"
)
repository
.
copy_gitattributes
(
"master"
)
end
context
'when gitaly is disabled'
,
:disable_gitaly
do
it_behaves_like
'applying git attributes'
it
"does not have an info/attributes"
do
expect
(
File
.
exist?
(
attributes_path
)).
to
be_falsey
end
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