diff options
| author | Douwe Maan <douwe@gitlab.com> | 2018-01-09 11:37:46 +0000 |
|---|---|---|
| committer | Douwe Maan <douwe@gitlab.com> | 2018-01-09 11:37:46 +0000 |
| commit | 088de97c3d86d9cf615538836527d23dbccd9712 (patch) | |
| tree | 664cec51e2cf931af4cc2efc1ef098857cefcd99 /lib/api | |
| parent | 4eae806af4874d5d2540a78f51fcbf72b9f69287 (diff) | |
| parent | f6c1d382591fd837e96e99ff115b7beb0e6b3f43 (diff) | |
| download | gitlab-ce-088de97c3d86d9cf615538836527d23dbccd9712.tar.gz | |
Merge branch 'fj-41681-add-param-disable-commit-stats-api' into 'master'
Add option to disable commit stats to commit API
Closes #41681
See merge request gitlab-org/gitlab-ce!16309
Diffstat (limited to 'lib/api')
| -rw-r--r-- | lib/api/commits.rb | 3 | ||||
| -rw-r--r-- | lib/api/entities.rb | 2 | ||||
| -rw-r--r-- | lib/api/v3/commits.rb | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 38e05074353..d8fd6a6eb06 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -82,13 +82,14 @@ module API end params do requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag' + optional :stats, type: Boolean, default: true, desc: 'Include commit stats' end get ':id/repository/commits/:sha', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do commit = user_project.commit(params[:sha]) not_found! 'Commit' unless commit - present commit, with: Entities::CommitDetail + present commit, with: Entities::CommitDetail, stats: params[:stats] end desc 'Get the diff for a specific commit of a project' do diff --git a/lib/api/entities.rb b/lib/api/entities.rb index bd0c54a1b04..f574858be02 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -278,7 +278,7 @@ module API end class CommitDetail < Commit - expose :stats, using: Entities::CommitStats + expose :stats, using: Entities::CommitStats, if: :stats expose :status expose :last_pipeline, using: 'API::Entities::PipelineBasic' end diff --git a/lib/api/v3/commits.rb b/lib/api/v3/commits.rb index 0ef26aa696a..4f6ea8f502e 100644 --- a/lib/api/v3/commits.rb +++ b/lib/api/v3/commits.rb @@ -71,13 +71,14 @@ module API end params do requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag' + optional :stats, type: Boolean, default: true, desc: 'Include commit stats' end get ":id/repository/commits/:sha", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do commit = user_project.commit(params[:sha]) not_found! "Commit" unless commit - present commit, with: ::API::Entities::CommitDetail + present commit, with: ::API::Entities::CommitDetail, stats: params[:stats] end desc 'Get the diff for a specific commit of a project' do |
