Commit 7e71ec19 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'expose-last-pipeline-for-a-commit' into 'master'

Expose last pipeline details in API response when getting a single commit

Closes #35692

See merge request gitlab-org/gitlab-ce!13521
parents 87878732 f696b04c
---
title: Expose last pipeline details in API response when getting a single commit
merge_request: 13521
author: Mehdi Lahmam (@mehlah)
type: added
......@@ -181,6 +181,12 @@ Example response:
"parent_ids": [
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
],
"last_pipeline" : {
"id": 8,
"ref": "master",
"sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0"
"status": "created"
}
"stats": {
"additions": 15,
"deletions": 10,
......
......@@ -234,6 +234,7 @@ module API
class RepoCommitDetail < RepoCommit
expose :stats, using: Entities::RepoCommitStats
expose :status
expose :last_pipeline, using: 'API::Entities::PipelineBasic'
end
class RepoBranch < Grape::Entity
......
......@@ -5,11 +5,18 @@
{
"required" : [
"stats",
"status"
"status",
"last_pipeline"
],
"properties": {
"stats": { "$ref": "../commit_stats.json" },
"status": { "type": ["string", "null"] }
"status": { "type": ["string", "null"] },
"last_pipeline": {
"oneOf": [
{ "type": "null" },
{ "$ref": "../pipeline/basic.json" }
]
}
}
}
]
......
{
"type": "object",
"required" : [
"id",
"sha",
"ref",
"status"
],
"properties" : {
"id": { "type": "integer" },
"sha": { "type": "string" },
"ref": { "type": "string" },
"status": { "type": "string" }
},
"additionalProperties": false
}
......@@ -491,6 +491,7 @@ describe API::Commits do
expect(json_response['stats']['deletions']).to eq(commit.stats.deletions)
expect(json_response['stats']['total']).to eq(commit.stats.total)
expect(json_response['status']).to be_nil
expect(json_response['last_pipeline']).to be_nil
end
context 'when ref does not exist' do
......@@ -573,6 +574,10 @@ describe API::Commits do
expect(response).to have_http_status(200)
expect(response).to match_response_schema('public_api/v4/commit/detail')
expect(json_response['status']).to eq('created')
expect(json_response['last_pipeline']['id']).to eq(pipeline.id)
expect(json_response['last_pipeline']['ref']).to eq(pipeline.ref)
expect(json_response['last_pipeline']['sha']).to eq(pipeline.sha)
expect(json_response['last_pipeline']['status']).to eq(pipeline.status)
end
context 'when pipeline succeeds' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment