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
28bbb4cb
Commit
28bbb4cb
authored
Jan 26, 2018
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Gitlab::Git::Repository#write_config to Gitaly
- Add tests for Repository#write_config
parent
08e01343
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
2 deletions
+66
-2
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git.rb
lib/gitlab/git.rb
+1
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+13
-1
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+13
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+38
-0
No files found.
GITALY_SERVER_VERSION
View file @
28bbb4cb
0.7
6
.0
0.7
7
.0
lib/gitlab/git.rb
View file @
28bbb4cb
...
@@ -6,6 +6,7 @@ module Gitlab
...
@@ -6,6 +6,7 @@ module Gitlab
CommandError
=
Class
.
new
(
StandardError
)
CommandError
=
Class
.
new
(
StandardError
)
CommitError
=
Class
.
new
(
StandardError
)
CommitError
=
Class
.
new
(
StandardError
)
OSError
=
Class
.
new
(
StandardError
)
class
<<
self
class
<<
self
include
Gitlab
::
EncodingHelper
include
Gitlab
::
EncodingHelper
...
...
lib/gitlab/git/repository.rb
View file @
28bbb4cb
...
@@ -1311,7 +1311,15 @@ module Gitlab
...
@@ -1311,7 +1311,15 @@ module Gitlab
# rubocop:enable Metrics/ParameterLists
# rubocop:enable Metrics/ParameterLists
def
write_config
(
full_path
:)
def
write_config
(
full_path
:)
rugged
.
config
[
'gitlab.fullpath'
]
=
full_path
if
full_path
.
present?
return
unless
full_path
.
present?
gitaly_migrate
(
:write_config
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
write_config
(
full_path:
full_path
)
else
rugged_write_config
(
full_path:
full_path
)
end
end
end
end
def
gitaly_repository
def
gitaly_repository
...
@@ -1451,6 +1459,10 @@ module Gitlab
...
@@ -1451,6 +1459,10 @@ module Gitlab
end
end
end
end
def
rugged_write_config
(
full_path
:)
rugged
.
config
[
'gitlab.fullpath'
]
=
full_path
end
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
28bbb4cb
...
@@ -219,6 +219,19 @@ module Gitlab
...
@@ -219,6 +219,19 @@ module Gitlab
true
true
end
end
def
write_config
(
full_path
:)
request
=
Gitaly
::
WriteConfigRequest
.
new
(
repository:
@gitaly_repo
,
full_path:
full_path
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:write_config
,
request
,
timeout:
GitalyClient
.
fast_timeout
)
raise
Gitlab
::
Git
::
OSError
.
new
(
response
.
error
)
unless
response
.
error
.
empty?
end
end
end
end
end
end
end
spec/lib/gitlab/git/repository_spec.rb
View file @
28bbb4cb
...
@@ -1790,6 +1790,44 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1790,6 +1790,44 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
end
end
describe
'#write_config'
do
before
do
repository
.
rugged
.
config
[
"gitlab.fullpath"
]
=
repository
.
path
end
shared_examples
'writing repo config'
do
context
'is given a path'
do
it
'writes it to disk'
do
repository
.
write_config
(
full_path:
"not-the/real-path.git"
)
config
=
File
.
read
(
File
.
join
(
repository
.
path
,
"config"
))
expect
(
config
).
to
include
(
"[gitlab]"
)
expect
(
config
).
to
include
(
"fullpath = not-the/real-path.git"
)
end
end
context
'it is given an empty path'
do
it
'does not write it to disk'
do
repository
.
write_config
(
full_path:
""
)
config
=
File
.
read
(
File
.
join
(
repository
.
path
,
"config"
))
expect
(
config
).
to
include
(
"[gitlab]"
)
expect
(
config
).
to
include
(
"fullpath =
#{
repository
.
path
}
"
)
end
end
end
context
"when gitaly_write_config is enabled"
do
it_behaves_like
"writing repo config"
end
context
"when gitaly_write_config is disabled"
,
:disable_gitaly
do
it_behaves_like
"writing repo config"
end
end
describe
'#merge'
do
describe
'#merge'
do
let
(
:repository
)
do
let
(
:repository
)
do
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_MUTABLE_REPO_PATH
,
''
)
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_MUTABLE_REPO_PATH
,
''
)
...
...
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