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
90f8feae
Commit
90f8feae
authored
Jun 23, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to new Gitaly commit message format
parent
7ee7d3f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
4 deletions
+59
-4
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+20
-0
lib/gitlab/gitaly_client/ref_service.rb
lib/gitlab/gitaly_client/ref_service.rb
+4
-4
spec/lib/gitlab/git/commit_spec.rb
spec/lib/gitlab/git/commit_spec.rb
+35
-0
No files found.
lib/gitlab/git/commit.rb
View file @
90f8feae
...
@@ -210,6 +210,8 @@ module Gitlab
...
@@ -210,6 +210,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 +373,24 @@ module Gitlab
...
@@ -371,6 +373,24 @@ 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
# NOTE: For ease of parsing in Gitaly, we have only the subject of
# the commit and not the full message.
# 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
.
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/gitaly_client/ref_service.rb
View file @
90f8feae
...
@@ -96,11 +96,11 @@ module Gitlab
...
@@ -96,11 +96,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
)
...
...
spec/lib/gitlab/git/commit_spec.rb
View file @
90f8feae
...
@@ -64,6 +64,41 @@ describe Gitlab::Git::Commit, seed_helper: true do
...
@@ -64,6 +64,41 @@ 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
(
: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
,
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
(
subject
)
}
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
)
}
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
...
...
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