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
4a072be2
Commit
4a072be2
authored
Sep 21, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: commits belong to project repository
parent
13155362
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
102 deletions
+77
-102
doc/api/commits.md
doc/api/commits.md
+0
-38
doc/api/projects.md
doc/api/projects.md
+34
-0
lib/api.rb
lib/api.rb
+0
-1
lib/api/commits.rb
lib/api/commits.rb
+0
-29
lib/api/entities.rb
lib/api/entities.rb
+4
-5
lib/api/projects.rb
lib/api/projects.rb
+18
-0
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+0
-29
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+21
-0
No files found.
doc/api/commits.md
deleted
100644 → 0
View file @
13155362
## List Commits
Get a list of project commits.
```
GET /projects/:id/commits
```
Parameters:
+
`id`
(required) - The ID or code name of a project
+
`ref_name`
(optional) - branch/tag name
+
`page`
(optional)
+
`per_page`
(optional)
```
json
[
{
"id"
:
"ed899a2f4b50b4370feeea94676502b42383c746"
,
"short_id"
:
"ed899a2f4b5"
,
"title"
:
"Replace sanitize with escape once"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dzaporozhets@sphereconsultinginc.com"
,
"created_at"
:
"2012-09-20T11:50:22+03:00"
},
{
"id"
:
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
,
"short_id"
:
"6104942438c"
,
"title"
:
"Sanitize for network graph"
,
"author_name"
:
"randx"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2012-09-20T09:06:12+03:00"
}
]
```
doc/api/projects.md
View file @
4a072be2
...
...
@@ -355,6 +355,40 @@ Parameters:
]
```
## Project repository commits
Get a list of repository commits in a project.
```
GET /projects/:id/repository/commits
```
Parameters:
+
`id`
(required) - The ID or code name of a project
+
`ref_name`
(optional) - The name of a repository branch or tag
```
json
[
{
"id"
:
"ed899a2f4b50b4370feeea94676502b42383c746"
,
"short_id"
:
"ed899a2f4b5"
,
"title"
:
"Replace sanitize with escape once"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dzaporozhets@sphereconsultinginc.com"
,
"created_at"
:
"2012-09-20T11:50:22+03:00"
},
{
"id"
:
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
,
"short_id"
:
"6104942438c"
,
"title"
:
"Sanitize for network graph"
,
"author_name"
:
"randx"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2012-09-20T09:06:12+03:00"
}
]
```
## Raw blob content
Get the raw file contents for a file.
...
...
lib/api.rb
View file @
4a072be2
...
...
@@ -19,6 +19,5 @@ module Gitlab
mount
Milestones
mount
Keys
mount
Session
mount
Commits
end
end
lib/api/commits.rb
deleted
100644 → 0
View file @
13155362
module
Gitlab
# Commits API
class
Commits
<
Grape
::
API
before
{
authenticate!
}
resource
:projects
do
# Get a list of project commits
#
# Parameters:
# id (required) - The ID or code name of a project
# ref_name (optional) - Name of branch or tag
# page (optional) - default is 0
# per_page (optional) - default is 20
# Example Request:
# GET /projects/:id/commits
get
":id/commits"
do
authorize!
:download_code
,
user_project
page
=
params
[
:page
]
||
0
per_page
=
params
[
:per_page
]
||
20
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
commits
=
user_project
.
commits
(
ref
,
nil
,
per_page
,
page
*
per_page
)
present
CommitDecorator
.
decorate
(
commits
),
with:
Entities
::
Commit
end
end
end
end
lib/api/entities.rb
View file @
4a072be2
...
...
@@ -17,11 +17,6 @@ module Gitlab
expose
:id
,
:url
end
class
Commit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:title
,
:author_name
,
:author_email
,
:created_at
end
class
Project
<
Grape
::
Entity
expose
:id
,
:code
,
:name
,
:description
,
:path
,
:default_branch
expose
:owner
,
using:
Entities
::
UserBasic
...
...
@@ -39,6 +34,10 @@ module Gitlab
expose
:name
,
:commit
end
class
RepoCommit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:title
,
:author_name
,
:author_email
,
:created_at
end
class
ProjectSnippet
<
Grape
::
Entity
expose
:id
,
:title
,
:file_name
expose
:author
,
using:
Entities
::
UserBasic
...
...
lib/api/projects.rb
View file @
4a072be2
...
...
@@ -211,6 +211,24 @@ module Gitlab
present
user_project
.
repo
.
tags
.
sort_by
(
&
:name
).
reverse
,
with:
Entities
::
RepoObject
end
# Get a project repository commits
#
# Parameters:
# id (required) - The ID or code name of a project
# ref_name (optional) - The name of a repository branch or tag
# Example Request:
# GET /projects/:id/repository/commits
get
":id/repository/commits"
do
authorize!
:download_code
,
user_project
page
=
params
[
:page
]
||
0
per_page
=
params
[
:per_page
]
||
20
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
commits
=
user_project
.
commits
(
ref
,
nil
,
per_page
,
page
*
per_page
)
present
CommitDecorator
.
decorate
(
commits
),
with:
Entities
::
RepoCommit
end
# Get a project snippet
#
# Parameters:
...
...
spec/requests/api/commits_spec.rb
deleted
100644 → 0
View file @
13155362
require
'spec_helper'
describe
Gitlab
::
API
do
include
ApiHelpers
let
(
:user
)
{
Factory
:user
}
let!
(
:project
)
{
Factory
:project
,
owner:
user
}
describe
"GET /projects/:id/commits"
do
context
"authorized user"
do
before
{
project
.
add_access
(
user
,
:read
)
}
it
"should return project commits"
do
get
api
(
"/projects/
#{
project
.
code
}
/commits"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'id'
].
should
==
project
.
commit
.
id
end
end
context
"unauthorized user"
do
it
"should return project commits"
do
get
api
(
"/projects/
#{
project
.
code
}
/commits"
)
response
.
status
.
should
==
401
end
end
end
end
spec/requests/api/projects_spec.rb
View file @
4a072be2
...
...
@@ -199,6 +199,27 @@ describe Gitlab::API do
end
end
describe
"GET /projects/:id/repository/commits"
do
context
"authorized user"
do
before
{
project
.
add_access
(
user2
,
:read
)
}
it
"should return project commits"
do
get
api
(
"/projects/
#{
project
.
code
}
/repository/commits"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'id'
].
should
==
project
.
commit
.
id
end
end
context
"unauthorized user"
do
it
"should not return project commits"
do
get
api
(
"/projects/
#{
project
.
code
}
/repository/commits"
)
response
.
status
.
should
==
401
end
end
end
describe
"GET /projects/:id/snippets/:snippet_id"
do
it
"should return a project snippet"
do
get
api
(
"/projects/
#{
project
.
code
}
/snippets/
#{
snippet
.
id
}
"
,
user
)
...
...
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