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
f112f5f2
Commit
f112f5f2
authored
Jul 19, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ee-gitaly-commits-between' into 'master'
Incorporate gitaly commits between See merge request !2418
parents
f1dd605d
779dc96a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
17 deletions
+118
-17
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
lib/gitlab/git/branch.rb
lib/gitlab/git/branch.rb
+4
-4
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+27
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+8
-8
lib/gitlab/gitaly_client/commit.rb
lib/gitlab/gitaly_client/commit.rb
+15
-0
lib/gitlab/gitaly_client/ref.rb
lib/gitlab/gitaly_client/ref.rb
+1
-1
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+46
-0
spec/lib/gitlab/gitaly_client/commit_spec.rb
spec/lib/gitlab/gitaly_client/commit_spec.rb
+15
-1
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+1
-1
No files found.
GITALY_SERVER_VERSION
View file @
f112f5f2
0.
17.0
0.
21.1
lib/gitlab/git/branch.rb
View file @
f112f5f2
...
@@ -28,11 +28,11 @@ module Gitlab
...
@@ -28,11 +28,11 @@ module Gitlab
id:
response
.
commit_id
,
id:
response
.
commit_id
,
message:
message
,
message:
message
,
authored_date:
Time
.
at
(
response
.
commit_author
.
date
.
seconds
),
authored_date:
Time
.
at
(
response
.
commit_author
.
date
.
seconds
),
author_name:
response
.
commit_author
.
name
,
author_name:
response
.
commit_author
.
name
.
dup
,
author_email:
response
.
commit_author
.
email
,
author_email:
response
.
commit_author
.
email
.
dup
,
committed_date:
Time
.
at
(
response
.
commit_committer
.
date
.
seconds
),
committed_date:
Time
.
at
(
response
.
commit_committer
.
date
.
seconds
),
committer_name:
response
.
commit_committer
.
name
,
committer_name:
response
.
commit_committer
.
name
.
dup
,
committer_email:
response
.
commit_committer
.
email
committer_email:
response
.
commit_committer
.
email
.
dup
}
}
Gitlab
::
Git
::
Commit
.
decorate
(
hash
)
Gitlab
::
Git
::
Commit
.
decorate
(
hash
)
...
...
lib/gitlab/git/commit.rb
View file @
f112f5f2
...
@@ -98,7 +98,15 @@ module Gitlab
...
@@ -98,7 +98,15 @@ module Gitlab
# Commit.between(repo, '29eda46b', 'master')
# Commit.between(repo, '29eda46b', 'master')
#
#
def
between
(
repo
,
base
,
head
)
def
between
(
repo
,
base
,
head
)
repo
.
commits_between
(
base
,
head
).
map
do
|
commit
|
commits
=
Gitlab
::
GitalyClient
.
migrate
(
:commits_between
)
do
|
is_enabled
|
if
is_enabled
repo
.
gitaly_commit_client
.
between
(
base
,
head
)
else
repo
.
commits_between
(
base
,
head
)
end
end
commits
.
map
do
|
commit
|
decorate
(
commit
)
decorate
(
commit
)
end
end
rescue
Rugged
::
ReferenceError
rescue
Rugged
::
ReferenceError
...
@@ -210,6 +218,8 @@ module Gitlab
...
@@ -210,6 +218,8 @@ module Gitlab
init_from_hash
(
raw_commit
)
init_from_hash
(
raw_commit
)
elsif
raw_commit
.
is_a?
(
Rugged
::
Commit
)
elsif
raw_commit
.
is_a?
(
Rugged
::
Commit
)
init_from_rugged
(
raw_commit
)
init_from_rugged
(
raw_commit
)
elsif
raw_commit
.
is_a?
(
Gitaly
::
GitCommit
)
init_from_gitaly
(
raw_commit
)
else
else
raise
"Invalid raw commit type:
#{
raw_commit
.
class
}
"
raise
"Invalid raw commit type:
#{
raw_commit
.
class
}
"
end
end
...
@@ -371,6 +381,22 @@ module Gitlab
...
@@ -371,6 +381,22 @@ module Gitlab
@parent_ids
=
commit
.
parents
.
map
(
&
:oid
)
@parent_ids
=
commit
.
parents
.
map
(
&
:oid
)
end
end
def
init_from_gitaly
(
commit
)
@raw_commit
=
commit
@id
=
commit
.
id
# TODO: Once gitaly "takes over" Rugged consider separating the
# subject from the message to make it clearer when there's one
# available but not the other.
@message
=
(
commit
.
body
.
presence
||
commit
.
subject
).
dup
@authored_date
=
Time
.
at
(
commit
.
author
.
date
.
seconds
)
@author_name
=
commit
.
author
.
name
.
dup
@author_email
=
commit
.
author
.
email
.
dup
@committed_date
=
Time
.
at
(
commit
.
committer
.
date
.
seconds
)
@committer_name
=
commit
.
committer
.
name
.
dup
@committer_email
=
commit
.
committer
.
email
.
dup
@parent_ids
=
commit
.
parent_ids
end
def
serialize_keys
def
serialize_keys
SERIALIZE_KEYS
SERIALIZE_KEYS
end
end
...
...
lib/gitlab/git/repository.rb
View file @
f112f5f2
...
@@ -835,6 +835,14 @@ module Gitlab
...
@@ -835,6 +835,14 @@ module Gitlab
Gitlab
::
GitalyClient
::
Util
.
repository
(
@storage
,
@relative_path
)
Gitlab
::
GitalyClient
::
Util
.
repository
(
@storage
,
@relative_path
)
end
end
def
gitaly_ref_client
@gitaly_ref_client
||=
Gitlab
::
GitalyClient
::
Ref
.
new
(
self
)
end
def
gitaly_commit_client
@gitaly_commit_client
||=
Gitlab
::
GitalyClient
::
Commit
.
new
(
self
)
end
private
private
def
raw_log
(
options
)
def
raw_log
(
options
)
...
@@ -1186,14 +1194,6 @@ module Gitlab
...
@@ -1186,14 +1194,6 @@ module Gitlab
end
end
end
end
def
gitaly_ref_client
@gitaly_ref_client
||=
Gitlab
::
GitalyClient
::
Ref
.
new
(
self
)
end
def
gitaly_commit_client
@gitaly_commit_client
||=
Gitlab
::
GitalyClient
::
Commit
.
new
(
self
)
end
def
gitaly_migrate
(
method
,
&
block
)
def
gitaly_migrate
(
method
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
&
block
)
Gitlab
::
GitalyClient
.
migrate
(
method
,
&
block
)
rescue
GRPC
::
NotFound
=>
e
rescue
GRPC
::
NotFound
=>
e
...
...
lib/gitlab/gitaly_client/commit.rb
View file @
f112f5f2
...
@@ -65,6 +65,17 @@ module Gitlab
...
@@ -65,6 +65,17 @@ module Gitlab
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:count_commits
,
request
).
count
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:count_commits
,
request
).
count
end
end
def
between
(
from
,
to
)
request
=
Gitaly
::
CommitsBetweenRequest
.
new
(
repository:
@gitaly_repo
,
from:
from
,
to:
to
)
response
=
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:commits_between
,
request
)
consume_commits_response
(
response
)
end
private
private
def
commit_diff_request_params
(
commit
,
options
=
{})
def
commit_diff_request_params
(
commit
,
options
=
{})
...
@@ -77,6 +88,10 @@ module Gitlab
...
@@ -77,6 +88,10 @@ module Gitlab
paths:
options
.
fetch
(
:paths
,
[])
paths:
options
.
fetch
(
:paths
,
[])
}
}
end
end
def
consume_commits_response
(
response
)
response
.
flat_map
{
|
r
|
r
.
commits
}
end
end
end
end
end
end
end
lib/gitlab/gitaly_client/ref.rb
View file @
f112f5f2
...
@@ -72,7 +72,7 @@ module Gitlab
...
@@ -72,7 +72,7 @@ module Gitlab
Gitlab
::
Git
::
Branch
.
new
(
Gitlab
::
Git
::
Branch
.
new
(
@repository
,
@repository
,
encode!
(
gitaly_branch
.
name
.
dup
),
encode!
(
gitaly_branch
.
name
.
dup
),
gitaly_branch
.
commit_id
gitaly_branch
)
)
end
end
end
end
...
...
spec/lib/gitlab/git/commit_spec.rb
View file @
f112f5f2
...
@@ -64,6 +64,52 @@ describe Gitlab::Git::Commit, seed_helper: true do
...
@@ -64,6 +64,52 @@ describe Gitlab::Git::Commit, seed_helper: true do
end
end
end
end
describe
"Commit info from gitaly commit"
do
let
(
:id
)
{
'f00'
}
let
(
:subject
)
{
"My commit"
.
force_encoding
(
'ASCII-8BIT'
)
}
let
(
:body
)
{
subject
+
"My body"
.
force_encoding
(
'ASCII-8BIT'
)
}
let
(
:committer
)
do
Gitaly
::
CommitAuthor
.
new
(
name:
generate
(
:name
),
email:
generate
(
:email
),
date:
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
123
)
)
end
let
(
:author
)
do
Gitaly
::
CommitAuthor
.
new
(
name:
generate
(
:name
),
email:
generate
(
:email
),
date:
Google
::
Protobuf
::
Timestamp
.
new
(
seconds:
456
)
)
end
let
(
:gitaly_commit
)
do
Gitaly
::
GitCommit
.
new
(
id:
id
,
subject:
subject
,
body:
body
,
author:
author
,
committer:
committer
)
end
let
(
:commit
)
{
described_class
.
new
(
gitaly_commit
)
}
it
{
expect
(
commit
.
short_id
).
to
eq
(
id
[
0
..
10
])
}
it
{
expect
(
commit
.
id
).
to
eq
(
id
)
}
it
{
expect
(
commit
.
sha
).
to
eq
(
id
)
}
it
{
expect
(
commit
.
safe_message
).
to
eq
(
body
)
}
it
{
expect
(
commit
.
created_at
).
to
eq
(
Time
.
at
(
committer
.
date
.
seconds
))
}
it
{
expect
(
commit
.
author_email
).
to
eq
(
author
.
email
)
}
it
{
expect
(
commit
.
author_name
).
to
eq
(
author
.
name
)
}
it
{
expect
(
commit
.
committer_name
).
to
eq
(
committer
.
name
)
}
it
{
expect
(
commit
.
committer_email
).
to
eq
(
committer
.
email
)
}
context
'no body'
do
let
(
:body
)
{
""
.
force_encoding
(
'ASCII-8BIT'
)
}
it
{
expect
(
commit
.
safe_message
).
to
eq
(
subject
)
}
end
end
context
'Class methods'
do
context
'Class methods'
do
describe
'.find'
do
describe
'.find'
do
it
"should return first head commit if without params"
do
it
"should return first head commit if without params"
do
...
...
spec/lib/gitlab/gitaly_client/commit_spec.rb
View file @
f112f5f2
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
GitalyClient
::
Commit
do
describe
Gitlab
::
GitalyClient
::
Commit
do
let
(
:diff_stub
)
{
double
(
'Gitaly::Diff::Stub'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:repository
)
{
project
.
repository
}
let
(
:repository_message
)
{
repository
.
gitaly_repository
}
let
(
:repository_message
)
{
repository
.
gitaly_repository
}
...
@@ -82,4 +81,19 @@ describe Gitlab::GitalyClient::Commit do
...
@@ -82,4 +81,19 @@ describe Gitlab::GitalyClient::Commit do
end
end
end
end
end
end
describe
'#between'
do
let
(
:from
)
{
'master'
}
let
(
:to
)
{
'4b825dc642cb6eb9a060e54bf8d69288fbee4904'
}
it
'sends an RPC request'
do
request
=
Gitaly
::
CommitsBetweenRequest
.
new
(
repository:
repository_message
,
from:
from
,
to:
to
)
expect_any_instance_of
(
Gitaly
::
CommitService
::
Stub
).
to
receive
(
:commits_between
)
.
with
(
request
,
kind_of
(
Hash
)).
and_return
([])
described_class
.
new
(
repository
).
between
(
from
,
to
)
end
end
end
end
spec/services/git_push_service_spec.rb
View file @
f112f5f2
...
@@ -122,7 +122,7 @@ describe GitPushService, services: true do
...
@@ -122,7 +122,7 @@ describe GitPushService, services: true do
it
{
is_expected
.
to
include
(
id:
commit
.
id
)
}
it
{
is_expected
.
to
include
(
id:
commit
.
id
)
}
it
{
is_expected
.
to
include
(
message:
commit
.
safe_message
)
}
it
{
is_expected
.
to
include
(
message:
commit
.
safe_message
)
}
it
{
is_expected
.
to
include
(
timestamp:
commit
.
date
.
xmlschema
)
}
it
{
expect
(
subject
[
:timestamp
].
in_time_zone
).
to
eq
(
commit
.
date
.
in_time_zone
)
}
it
do
it
do
is_expected
.
to
include
(
is_expected
.
to
include
(
url:
[
url:
[
...
...
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