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
c19ad3d5
Commit
c19ad3d5
authored
Apr 07, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gitaly-repository-message' into 'master'
Send more Gitaly::Repository fields See merge request !10499
parents
aa8260d2
20d415a6
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
46 additions
and
41 deletions
+46
-41
app/models/repository.rb
app/models/repository.rb
+2
-0
lib/api/internal.rb
lib/api/internal.rb
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+9
-1
lib/gitlab/gitaly_client/commit.rb
lib/gitlab/gitaly_client/commit.rb
+9
-12
lib/gitlab/gitaly_client/notifications.rb
lib/gitlab/gitaly_client/notifications.rb
+5
-4
lib/gitlab/gitaly_client/ref.rb
lib/gitlab/gitaly_client/ref.rb
+7
-6
lib/gitlab/gitaly_client/util.rb
lib/gitlab/gitaly_client/util.rb
+8
-6
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+2
-8
spec/lib/gitlab/gitaly_client/commit_spec.rb
spec/lib/gitlab/gitaly_client/commit_spec.rb
+1
-1
spec/lib/gitlab/gitaly_client/notifications_spec.rb
spec/lib/gitlab/gitaly_client/notifications_spec.rb
+1
-1
spec/lib/gitlab/gitaly_client/ref_spec.rb
spec/lib/gitlab/gitaly_client/ref_spec.rb
+1
-1
No files found.
app/models/repository.rb
View file @
c19ad3d5
...
@@ -1156,6 +1156,8 @@ class Repository
...
@@ -1156,6 +1156,8 @@ class Repository
@project
.
repository_storage_path
@project
.
repository_storage_path
end
end
delegate
:gitaly_channel
,
:gitaly_repository
,
to: :raw_repository
def
initialize_raw_repository
def
initialize_raw_repository
Gitlab
::
Git
::
Repository
.
new
(
project
.
repository_storage
,
path_with_namespace
+
'.git'
)
Gitlab
::
Git
::
Repository
.
new
(
project
.
repository_storage
,
path_with_namespace
+
'.git'
)
end
end
...
...
lib/api/internal.rb
View file @
c19ad3d5
...
@@ -142,7 +142,7 @@ module API
...
@@ -142,7 +142,7 @@ module API
project
=
Project
.
find_by_full_path
(
relative_path
.
sub
(
/\.(git|wiki)\z/
,
''
))
project
=
Project
.
find_by_full_path
(
relative_path
.
sub
(
/\.(git|wiki)\z/
,
''
))
begin
begin
Gitlab
::
GitalyClient
::
Notifications
.
new
(
project
.
repository
_storage
,
relative_path
).
post_receive
Gitlab
::
GitalyClient
::
Notifications
.
new
(
project
.
repository
).
post_receive
rescue
GRPC
::
Unavailable
=>
e
rescue
GRPC
::
Unavailable
=>
e
render_api_error
(
e
,
500
)
render_api_error
(
e
,
500
)
end
end
...
...
lib/gitlab/git/repository.rb
View file @
c19ad3d5
...
@@ -968,6 +968,14 @@ module Gitlab
...
@@ -968,6 +968,14 @@ module Gitlab
@attributes
.
attributes
(
path
)
@attributes
.
attributes
(
path
)
end
end
def
gitaly_repository
Gitlab
::
GitalyClient
::
Util
.
repository
(
@repository_storage
,
@relative_path
)
end
def
gitaly_channel
Gitlab
::
GitalyClient
.
get_channel
(
@repository_storage
)
end
private
private
# Get the content of a blob for a given commit. If the blob is a commit
# Get the content of a blob for a given commit. If the blob is a commit
...
@@ -1247,7 +1255,7 @@ module Gitlab
...
@@ -1247,7 +1255,7 @@ module Gitlab
end
end
def
gitaly_ref_client
def
gitaly_ref_client
@gitaly_ref_client
||=
Gitlab
::
GitalyClient
::
Ref
.
new
(
@repository_storage
,
@relative_path
)
@gitaly_ref_client
||=
Gitlab
::
GitalyClient
::
Ref
.
new
(
self
)
end
end
end
end
end
end
...
...
lib/gitlab/gitaly_client/commit.rb
View file @
c19ad3d5
...
@@ -7,14 +7,13 @@ module Gitlab
...
@@ -7,14 +7,13 @@ module Gitlab
class
<<
self
class
<<
self
def
diff_from_parent
(
commit
,
options
=
{})
def
diff_from_parent
(
commit
,
options
=
{})
project
=
commit
.
project
repository
=
commit
.
project
.
repository
channel
=
GitalyClient
.
get_channel
(
project
.
repository_storage
)
gitaly_repo
=
repository
.
gitaly_repository
stub
=
Gitaly
::
Diff
::
Stub
.
new
(
nil
,
nil
,
channel_override:
channel
)
stub
=
Gitaly
::
Diff
::
Stub
.
new
(
nil
,
nil
,
channel_override:
repository
.
gitaly_channel
)
repo
=
Gitaly
::
Repository
.
new
(
path:
project
.
repository
.
path_to_repo
)
parent
=
commit
.
parents
[
0
]
parent
=
commit
.
parents
[
0
]
parent_id
=
parent
?
parent
.
id
:
EMPTY_TREE_ID
parent_id
=
parent
?
parent
.
id
:
EMPTY_TREE_ID
request
=
Gitaly
::
CommitDiffRequest
.
new
(
request
=
Gitaly
::
CommitDiffRequest
.
new
(
repository:
repo
,
repository:
gitaly_
repo
,
left_commit_id:
parent_id
,
left_commit_id:
parent_id
,
right_commit_id:
commit
.
id
right_commit_id:
commit
.
id
)
)
...
@@ -23,12 +22,10 @@ module Gitlab
...
@@ -23,12 +22,10 @@ module Gitlab
end
end
def
is_ancestor
(
repository
,
ancestor_id
,
child_id
)
def
is_ancestor
(
repository
,
ancestor_id
,
child_id
)
project
=
Project
.
find_by_path
(
repository
.
path
)
gitaly_repo
=
repository
.
gitaly_repository
channel
=
GitalyClient
.
get_channel
(
project
.
repository_storage
)
stub
=
Gitaly
::
Commit
::
Stub
.
new
(
nil
,
nil
,
channel_override:
repository
.
gitaly_channel
)
stub
=
Gitaly
::
Commit
::
Stub
.
new
(
nil
,
nil
,
channel_override:
channel
)
repo
=
Gitaly
::
Repository
.
new
(
path:
repository
.
path_to_repo
)
request
=
Gitaly
::
CommitIsAncestorRequest
.
new
(
request
=
Gitaly
::
CommitIsAncestorRequest
.
new
(
repository:
repo
,
repository:
gitaly_
repo
,
ancestor_id:
ancestor_id
,
ancestor_id:
ancestor_id
,
child_id:
child_id
child_id:
child_id
)
)
...
...
lib/gitlab/gitaly_client/notifications.rb
View file @
c19ad3d5
...
@@ -3,13 +3,14 @@ module Gitlab
...
@@ -3,13 +3,14 @@ module Gitlab
class
Notifications
class
Notifications
attr_accessor
:stub
attr_accessor
:stub
def
initialize
(
repository_storage
,
relative_path
)
# 'repository' is a Gitlab::Git::Repository
@channel
,
@repository
=
Util
.
process_path
(
repository_storage
,
relative_path
)
def
initialize
(
repository
)
@stub
=
Gitaly
::
Notifications
::
Stub
.
new
(
nil
,
nil
,
channel_override:
@channel
)
@gitaly_repo
=
repository
.
gitaly_repository
@stub
=
Gitaly
::
Notifications
::
Stub
.
new
(
nil
,
nil
,
channel_override:
repository
.
gitaly_channel
)
end
end
def
post_receive
def
post_receive
request
=
Gitaly
::
PostReceiveRequest
.
new
(
repository:
@
repository
)
request
=
Gitaly
::
PostReceiveRequest
.
new
(
repository:
@
gitaly_repo
)
@stub
.
post_receive
(
request
)
@stub
.
post_receive
(
request
)
end
end
end
end
...
...
lib/gitlab/gitaly_client/ref.rb
View file @
c19ad3d5
...
@@ -3,23 +3,24 @@ module Gitlab
...
@@ -3,23 +3,24 @@ module Gitlab
class
Ref
class
Ref
attr_accessor
:stub
attr_accessor
:stub
def
initialize
(
repository_storage
,
relative_path
)
# 'repository' is a Gitlab::Git::Repository
@channel
,
@repository
=
Util
.
process_path
(
repository_storage
,
relative_path
)
def
initialize
(
repository
)
@stub
=
Gitaly
::
Ref
::
Stub
.
new
(
nil
,
nil
,
channel_override:
@channel
)
@gitaly_repo
=
repository
.
gitaly_repository
@stub
=
Gitaly
::
Ref
::
Stub
.
new
(
nil
,
nil
,
channel_override:
repository
.
gitaly_channel
)
end
end
def
default_branch_name
def
default_branch_name
request
=
Gitaly
::
FindDefaultBranchNameRequest
.
new
(
repository:
@
repository
)
request
=
Gitaly
::
FindDefaultBranchNameRequest
.
new
(
repository:
@
gitaly_repo
)
stub
.
find_default_branch_name
(
request
).
name
.
gsub
(
/^refs\/heads\//
,
''
)
stub
.
find_default_branch_name
(
request
).
name
.
gsub
(
/^refs\/heads\//
,
''
)
end
end
def
branch_names
def
branch_names
request
=
Gitaly
::
FindAllBranchNamesRequest
.
new
(
repository:
@
repository
)
request
=
Gitaly
::
FindAllBranchNamesRequest
.
new
(
repository:
@
gitaly_repo
)
consume_refs_response
(
stub
.
find_all_branch_names
(
request
),
prefix:
'refs/heads/'
)
consume_refs_response
(
stub
.
find_all_branch_names
(
request
),
prefix:
'refs/heads/'
)
end
end
def
tag_names
def
tag_names
request
=
Gitaly
::
FindAllTagNamesRequest
.
new
(
repository:
@
repository
)
request
=
Gitaly
::
FindAllTagNamesRequest
.
new
(
repository:
@
gitaly_repo
)
consume_refs_response
(
stub
.
find_all_tag_names
(
request
),
prefix:
'refs/tags/'
)
consume_refs_response
(
stub
.
find_all_tag_names
(
request
),
prefix:
'refs/tags/'
)
end
end
...
...
lib/gitlab/gitaly_client/util.rb
View file @
c19ad3d5
module
Gitlab
module
Gitlab
module
GitalyClient
module
GitalyClient
module
Util
module
Util
def
self
.
process_path
(
repository_storage
,
relative_path
)
class
<<
self
channel
=
GitalyClient
.
get_channel
(
repository_storage
)
def
repository
(
repository_storage
,
relative_path
)
storage_path
=
Gitlab
.
config
.
repositories
.
storages
[
repository_storage
][
'path'
]
Gitaly
::
Repository
.
new
(
repository
=
Gitaly
::
Repository
.
new
(
path:
File
.
join
(
storage_path
,
relative_path
))
path:
File
.
join
(
Gitlab
.
config
.
repositories
.
storages
[
repository_storage
][
'path'
],
relative_path
),
storage_name:
repository_storage
,
[
channel
,
repository
]
relative_path:
relative_path
,
)
end
end
end
end
end
end
end
...
...
lib/gitlab/workhorse.rb
View file @
c19ad3d5
...
@@ -24,14 +24,8 @@ module Gitlab
...
@@ -24,14 +24,8 @@ module Gitlab
}
}
if
Gitlab
.
config
.
gitaly
.
enabled
if
Gitlab
.
config
.
gitaly
.
enabled
storage
=
repository
.
project
.
repository_storage
address
=
Gitlab
::
GitalyClient
.
get_address
(
repository
.
project
.
repository_storage
)
address
=
Gitlab
::
GitalyClient
.
get_address
(
storage
)
params
[
:Repository
]
=
repository
.
gitaly_repository
.
to_h
# TODO: use GitalyClient code to assemble the Repository message
params
[
:Repository
]
=
Gitaly
::
Repository
.
new
(
path:
repo_path
,
storage_name:
storage
,
relative_path:
Gitlab
::
RepoPath
.
strip_storage_path
(
repo_path
),
).
to_h
feature_enabled
=
case
action
.
to_s
feature_enabled
=
case
action
.
to_s
when
'git_receive_pack'
when
'git_receive_pack'
...
...
spec/lib/gitlab/gitaly_client/commit_spec.rb
View file @
c19ad3d5
...
@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Commit do
...
@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Commit do
describe
'.diff_from_parent'
do
describe
'.diff_from_parent'
do
let
(
:diff_stub
)
{
double
(
'Gitaly::Diff::Stub'
)
}
let
(
:diff_stub
)
{
double
(
'Gitaly::Diff::Stub'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository_message
)
{
Gitaly
::
Repository
.
new
(
path:
project
.
repository
.
path
)
}
let
(
:repository_message
)
{
project
.
repository
.
gitaly_repository
}
let
(
:commit
)
{
project
.
commit
(
'913c66a37b4a45b9769037c55c2d238bd0942d2e'
)
}
let
(
:commit
)
{
project
.
commit
(
'913c66a37b4a45b9769037c55c2d238bd0942d2e'
)
}
before
do
before
do
...
...
spec/lib/gitlab/gitaly_client/notifications_spec.rb
View file @
c19ad3d5
...
@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Notifications do
...
@@ -4,7 +4,7 @@ describe Gitlab::GitalyClient::Notifications do
describe
'#post_receive'
do
describe
'#post_receive'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:repo_path
)
{
project
.
repository
.
path_to_repo
}
let
(
:repo_path
)
{
project
.
repository
.
path_to_repo
}
subject
{
described_class
.
new
(
project
.
repository
_storage
,
project
.
full_path
+
'.git'
)
}
subject
{
described_class
.
new
(
project
.
repository
)
}
it
'sends a post_receive message'
do
it
'sends a post_receive message'
do
expect_any_instance_of
(
Gitaly
::
Notifications
::
Stub
).
expect_any_instance_of
(
Gitaly
::
Notifications
::
Stub
).
...
...
spec/lib/gitlab/gitaly_client/ref_spec.rb
View file @
c19ad3d5
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
GitalyClient
::
Ref
do
describe
Gitlab
::
GitalyClient
::
Ref
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:repo_path
)
{
project
.
repository
.
path_to_repo
}
let
(
:repo_path
)
{
project
.
repository
.
path_to_repo
}
let
(
:client
)
{
Gitlab
::
GitalyClient
::
Ref
.
new
(
project
.
repository
_storage
,
project
.
full_path
+
'.git'
)
}
let
(
:client
)
{
Gitlab
::
GitalyClient
::
Ref
.
new
(
project
.
repository
)
}
before
do
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:enabled
).
and_return
(
true
)
...
...
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