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
a87cca5f
Commit
a87cca5f
authored
7 years ago
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Gitaly annotations
parent
b2ecf0aa
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
0 deletions
+22
-0
app/models/repository.rb
app/models/repository.rb
+2
-0
app/services/git_operation_service.rb
app/services/git_operation_service.rb
+1
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+4
-0
lib/gitlab/git_ref_validator.rb
lib/gitlab/git_ref_validator.rb
+2
-0
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+13
-0
No files found.
app/models/repository.rb
View file @
a87cca5f
...
...
@@ -123,6 +123,7 @@ class Repository
commits
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/384
def
find_commits_by_message
(
query
,
ref
=
nil
,
path
=
nil
,
limit
=
1000
,
offset
=
0
)
unless
exists?
&&
has_visible_content?
&&
query
.
present?
return
[]
...
...
@@ -610,6 +611,7 @@ class Repository
commit
(
sha
)
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/383
def
last_commit_id_for_path
(
sha
,
path
)
key
=
path
.
blank?
?
"last_commit_id_for_path:
#{
sha
}
"
:
"last_commit_id_for_path:
#{
sha
}
:
#{
Digest
::
SHA1
.
hexdigest
(
path
)
}
"
...
...
This diff is collapsed.
Click to expand it.
app/services/git_operation_service.rb
View file @
a87cca5f
...
...
@@ -129,6 +129,7 @@ class GitOperationService
end
end
# Gitaly note: JV: wait with migrating #update_ref until we know how to migrate its call sites.
def
update_ref
(
ref
,
newrev
,
oldrev
)
# We use 'git update-ref' because libgit2/rugged currently does not
# offer 'compare and swap' ref updates. Without compare-and-swap we can
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/git/repository.rb
View file @
a87cca5f
...
...
@@ -334,6 +334,7 @@ module Gitlab
raw_log
(
options
).
map
{
|
c
|
Commit
.
decorate
(
c
)
}
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/382
def
count_commits
(
options
)
cmd
=
%W[
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
rev-list]
cmd
<<
"--after=
#{
options
[
:after
].
iso8601
}
"
if
options
[
:after
]
...
...
@@ -884,6 +885,9 @@ module Gitlab
Rugged
::
Walker
.
walk
(
rugged
,
walk_options
).
to_a
end
# Gitaly note: JV: although #log_by_shell shells out to Git I think the
# complexity is such that we should migrate it as Ruby before trying to
# do it in Go.
def
log_by_shell
(
sha
,
options
)
limit
=
options
[
:limit
].
to_i
offset
=
options
[
:offset
].
to_i
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/git_ref_validator.rb
View file @
a87cca5f
# Gitaly note: JV: does not need to be migrated, works without a repo.
module
Gitlab
module
GitRefValidator
extend
self
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/shell.rb
View file @
a87cca5f
# Gitaly note: JV: two sets of straightforward RPC's. 1 Hard RPC: fork_repository.
# SSH key operations are not part of Gitaly so will never be migrated.
require
'securerandom'
module
Gitlab
...
...
@@ -68,6 +71,7 @@ module Gitlab
# Ex.
# add_repository("/path/to/storage", "gitlab/gitlab-ci")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387
def
add_repository
(
storage
,
name
)
gitlab_shell_fast_execute
([
gitlab_shell_projects_path
,
'add-project'
,
storage
,
"
#{
name
}
.git"
])
...
...
@@ -81,6 +85,7 @@ module Gitlab
# Ex.
# import_repository("/path/to/storage", "gitlab/gitlab-ci", "https://github.com/randx/six.git")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387
def
import_repository
(
storage
,
name
,
url
)
# Timeout should be less than 900 ideally, to prevent the memory killer
# to silently kill the process without knowing we are timing out here.
...
...
@@ -99,6 +104,7 @@ module Gitlab
# Ex.
# fetch_remote("gitlab/gitlab-ci", "upstream")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387
def
fetch_remote
(
storage
,
name
,
remote
,
forced:
false
,
no_tags:
false
)
args
=
[
gitlab_shell_projects_path
,
'fetch-remote'
,
storage
,
"
#{
name
}
.git"
,
remote
,
"
#{
Gitlab
.
config
.
gitlab_shell
.
git_timeout
}
"
]
args
<<
'--force'
if
forced
...
...
@@ -115,6 +121,7 @@ module Gitlab
# Ex.
# mv_repository("/path/to/storage", "gitlab/gitlab-ci", "randx/gitlab-ci-new")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387
def
mv_repository
(
storage
,
path
,
new_path
)
gitlab_shell_fast_execute
([
gitlab_shell_projects_path
,
'mv-project'
,
storage
,
"
#{
path
}
.git"
,
"
#{
new_path
}
.git"
])
...
...
@@ -129,6 +136,7 @@ module Gitlab
# Ex.
# fork_repository("/path/to/forked_from/storage", "gitlab/gitlab-ci", "/path/to/forked_to/storage", "randx")
#
# Gitaly note: JV: not easy to migrate because this involves two Gitaly servers, not one.
def
fork_repository
(
forked_from_storage
,
path
,
forked_to_storage
,
fork_namespace
)
gitlab_shell_fast_execute
([
gitlab_shell_projects_path
,
'fork-project'
,
forked_from_storage
,
"
#{
path
}
.git"
,
forked_to_storage
,
...
...
@@ -143,6 +151,7 @@ module Gitlab
# Ex.
# remove_repository("/path/to/storage", "gitlab/gitlab-ci")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/387
def
remove_repository
(
storage
,
name
)
gitlab_shell_fast_execute
([
gitlab_shell_projects_path
,
'rm-project'
,
storage
,
"
#{
name
}
.git"
])
...
...
@@ -194,6 +203,7 @@ module Gitlab
# Ex.
# add_namespace("/path/to/storage", "gitlab")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/385
def
add_namespace
(
storage
,
name
)
path
=
full_path
(
storage
,
name
)
FileUtils
.
mkdir_p
(
path
,
mode:
0770
)
unless
exists?
(
storage
,
name
)
...
...
@@ -207,6 +217,7 @@ module Gitlab
# Ex.
# rm_namespace("/path/to/storage", "gitlab")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/385
def
rm_namespace
(
storage
,
name
)
FileUtils
.
rm_r
(
full_path
(
storage
,
name
),
force:
true
)
end
...
...
@@ -216,6 +227,7 @@ module Gitlab
# Ex.
# mv_namespace("/path/to/storage", "gitlab", "gitlabhq")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/385
def
mv_namespace
(
storage
,
old_name
,
new_name
)
return
false
if
exists?
(
storage
,
new_name
)
||
!
exists?
(
storage
,
old_name
)
...
...
@@ -241,6 +253,7 @@ module Gitlab
# exists?(storage, 'gitlab')
# exists?(storage, 'gitlab/cookies.git')
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/385
def
exists?
(
storage
,
dir_name
)
File
.
exist?
(
full_path
(
storage
,
dir_name
))
end
...
...
This diff is collapsed.
Click to expand it.
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