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
10fb904d
Commit
10fb904d
authored
Jan 17, 2018
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Git::Repository#write_ref to Gitaly
parent
44edd111
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
app/models/repository.rb
app/models/repository.rb
+2
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+16
-4
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+16
-0
No files found.
app/models/repository.rb
View file @
10fb904d
...
@@ -255,6 +255,8 @@ class Repository
...
@@ -255,6 +255,8 @@ class Repository
# This will still fail if the file is corrupted (e.g. 0 bytes)
# This will still fail if the file is corrupted (e.g. 0 bytes)
raw_repository
.
write_ref
(
keep_around_ref_name
(
sha
),
sha
,
shell:
false
)
raw_repository
.
write_ref
(
keep_around_ref_name
(
sha
),
sha
,
shell:
false
)
rescue
Gitlab
::
Git
::
CommandError
=>
ex
Rails
.
logger
.
error
"Unable to create keep-around reference for repository
#{
path
}
:
#{
ex
}
"
end
end
def
kept_around?
(
sha
)
def
kept_around?
(
sha
)
...
...
lib/gitlab/git/repository.rb
View file @
10fb904d
...
@@ -1105,10 +1105,14 @@ module Gitlab
...
@@ -1105,10 +1105,14 @@ module Gitlab
end
end
def
write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
def
write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
if
shell
ref_path
=
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
ref_path
}
"
unless
ref_path
.
start_with?
(
"refs/"
)
||
ref_path
==
"HEAD"
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
else
gitaly_migrate
(
:write_ref
)
do
|
is_enabled
|
rugged_write_ref
(
ref_path
,
ref
)
if
is_enabled
gitaly_repository_client
.
write_ref
(
ref_path
,
ref
,
old_ref
,
shell
)
else
local_write_ref
(
ref_path
,
ref
,
old_ref:
old_ref
,
shell:
shell
)
end
end
end
end
end
...
@@ -1419,6 +1423,14 @@ module Gitlab
...
@@ -1419,6 +1423,14 @@ module Gitlab
private
private
def
local_write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
if
shell
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
else
rugged_write_ref
(
ref_path
,
ref
)
end
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 @
10fb904d
...
@@ -203,6 +203,22 @@ module Gitlab
...
@@ -203,6 +203,22 @@ module Gitlab
timeout:
GitalyClient
.
default_timeout
timeout:
GitalyClient
.
default_timeout
)
)
end
end
def
write_ref
(
ref_path
,
ref
,
old_ref
,
shell
)
request
=
Gitaly
::
WriteRefRequest
.
new
(
repository:
@gitaly_repo
,
ref:
ref_path
.
b
,
revision:
ref
.
b
,
shell:
shell
)
request
.
old_revision
=
old_ref
.
b
unless
old_ref
.
nil?
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:write_ref
,
request
)
raise
Gitlab
::
Git
::
CommandError
,
encode!
(
response
.
error
)
if
response
.
error
.
present?
true
end
end
end
end
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