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
9f5aabaa
Commit
9f5aabaa
authored
Jan 31, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Jan 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate commit entities into own classes
parent
4816319c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
45 deletions
+80
-45
changelogs/unreleased/refactoring-entities-file-7.yml
changelogs/unreleased/refactoring-entities-file-7.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-45
lib/api/entities/commit.rb
lib/api/entities/commit.rb
+14
-0
lib/api/entities/commit_detail.rb
lib/api/entities/commit_detail.rb
+22
-0
lib/api/entities/commit_signature.rb
lib/api/entities/commit_signature.rb
+12
-0
lib/api/entities/commit_stats.rb
lib/api/entities/commit_stats.rb
+9
-0
lib/api/entities/commit_with_stats.rb
lib/api/entities/commit_with_stats.rb
+9
-0
lib/api/entities/diff_refs.rb
lib/api/entities/diff_refs.rb
+9
-0
No files found.
changelogs/unreleased/refactoring-entities-file-7.yml
0 → 100644
View file @
9f5aabaa
---
title
:
Separate commit entities into own class files
merge_request
:
24085
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
9f5aabaa
...
@@ -128,51 +128,6 @@ module API
...
@@ -128,51 +128,6 @@ module API
end
end
end
end
class
DiffRefs
<
Grape
::
Entity
expose
:base_sha
,
:head_sha
,
:start_sha
end
class
Commit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:created_at
expose
:parent_ids
expose
:full_title
,
as: :title
expose
:safe_message
,
as: :message
expose
:author_name
,
:author_email
,
:authored_date
expose
:committer_name
,
:committer_email
,
:committed_date
end
class
CommitStats
<
Grape
::
Entity
expose
:additions
,
:deletions
,
:total
end
class
CommitWithStats
<
Commit
expose
:stats
,
using:
Entities
::
CommitStats
end
class
CommitDetail
<
Commit
expose
:stats
,
using:
Entities
::
CommitStats
,
if: :stats
expose
:status
expose
:project_id
expose
:last_pipeline
do
|
commit
,
options
|
pipeline
=
commit
.
last_pipeline
if
can_read_pipeline?
::
API
::
Entities
::
PipelineBasic
.
represent
(
pipeline
,
options
)
end
private
def
can_read_pipeline?
Ability
.
allowed?
(
options
[
:current_user
],
:read_pipeline
,
object
.
last_pipeline
)
end
end
class
CommitSignature
<
Grape
::
Entity
expose
:gpg_key_id
expose
:gpg_key_primary_keyid
,
:gpg_key_user_name
,
:gpg_key_user_email
expose
:verification_status
expose
:gpg_key_subkey_id
end
class
BasicRef
<
Grape
::
Entity
class
BasicRef
<
Grape
::
Entity
expose
:type
,
:name
expose
:type
,
:name
end
end
...
...
lib/api/entities/commit.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
Commit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:created_at
expose
:parent_ids
expose
:full_title
,
as: :title
expose
:safe_message
,
as: :message
expose
:author_name
,
:author_email
,
:authored_date
expose
:committer_name
,
:committer_email
,
:committed_date
end
end
end
lib/api/entities/commit_detail.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
CommitDetail
<
Commit
expose
:stats
,
using:
Entities
::
CommitStats
,
if: :stats
expose
:status
expose
:project_id
expose
:last_pipeline
do
|
commit
,
options
|
pipeline
=
commit
.
last_pipeline
if
can_read_pipeline?
::
API
::
Entities
::
PipelineBasic
.
represent
(
pipeline
,
options
)
end
private
def
can_read_pipeline?
Ability
.
allowed?
(
options
[
:current_user
],
:read_pipeline
,
object
.
last_pipeline
)
end
end
end
end
lib/api/entities/commit_signature.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
CommitSignature
<
Grape
::
Entity
expose
:gpg_key_id
expose
:gpg_key_primary_keyid
,
:gpg_key_user_name
,
:gpg_key_user_email
expose
:verification_status
expose
:gpg_key_subkey_id
end
end
end
lib/api/entities/commit_stats.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
CommitStats
<
Grape
::
Entity
expose
:additions
,
:deletions
,
:total
end
end
end
lib/api/entities/commit_with_stats.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
CommitWithStats
<
Commit
expose
:stats
,
using:
Entities
::
CommitStats
end
end
end
lib/api/entities/diff_refs.rb
0 → 100644
View file @
9f5aabaa
# frozen_string_literal: true
module
API
module
Entities
class
DiffRefs
<
Grape
::
Entity
expose
:base_sha
,
:head_sha
,
:start_sha
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