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
Léo-Paul Géneau
gitlab-ce
Commits
cea2a8f7
Commit
cea2a8f7
authored
Oct 24, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic ref fetching for commits
parent
7534f7a8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
lib/api/commits.rb
lib/api/commits.rb
+25
-0
lib/api/entities.rb
lib/api/entities.rb
+13
-3
No files found.
lib/api/commits.rb
View file @
cea2a8f7
...
...
@@ -156,6 +156,31 @@ module API
end
end
desc
'Get all reference a commit is pushed to'
do
detail
'This feature was introduced in GitLab 10.6'
success
Entities
::
SimpleRef
end
params
do
requires
:sha
,
type:
String
,
desc:
'A commit sha'
optional
:type
,
type:
String
,
values:
%w(branches tags all)
,
default:
'all'
,
desc:
'Scope'
end
get
':id/repository/commits/:sha/refs'
,
requirements:
API
::
COMMIT_ENDPOINT_REQUIREMENTS
do
commit
=
user_project
.
commit
(
params
[
:sha
])
not_found!
(
'Commit'
)
unless
commit
case
params
[
:type
]
when
'branches'
refs
=
user_project
.
repository
.
branch_names_contains
(
commit
.
id
)
when
'tags'
refs
=
user_project
.
repository
.
tag_names_contains
(
commit
.
id
)
else
refs
=
user_project
.
repository
.
branch_names_contains
(
commit
.
id
)
refs
.
push
(
*
user_project
.
repository
.
tag_names_contains
(
commit
.
id
))
end
present
refs
,
with:
Entities
::
SimpleRef
end
desc
'Post comment to commit'
do
success
Entities
::
CommitNote
end
...
...
lib/api/entities.rb
View file @
cea2a8f7
...
...
@@ -276,7 +276,17 @@ module API
expose
:last_pipeline
,
using:
'API::Entities::PipelineBasic'
end
class
Branch
<
Grape
::
Entity
class
BasicRef
<
Grape
::
Entity
expose
:name
end
class
SimpleRef
<
Grape
::
Entity
expose
:name
do
|
ref
,
options
|
ref
end
end
class
Branch
<
BasicRef
expose
:name
expose
:commit
,
using:
Entities
::
Commit
do
|
repo_branch
,
options
|
...
...
@@ -845,8 +855,8 @@ module API
expose
:description
end
class
Tag
<
Grape
::
Entity
expose
:
name
,
:
message
class
Tag
<
BasicRef
expose
:message
expose
:commit
,
using:
Entities
::
Commit
do
|
repo_tag
,
options
|
options
[
:project
].
repository
.
commit
(
repo_tag
.
dereferenced_target
)
...
...
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