summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-02-29 13:54:33 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-02-29 13:54:33 +0100
commitdcc67ac1fdf21f3e9b301ba91acadf8adadc1cf9 (patch)
treef3a52106997087a12b56b56f7f83ff69c3856d94 /lib
parent17251cf447c5a7d2823d892e6dc1c4b27a268a25 (diff)
downloadgitlab-ce-dcc67ac1fdf21f3e9b301ba91acadf8adadc1cf9.tar.gz
Return empty array when commit has no statuses in API
This makes API endpoint for Commit Statuses return empty array instead of 404 when commit exists, but has no statuses. Closes #3080
Diffstat (limited to 'lib')
-rw-r--r--lib/api/commit_statuses.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 9422d438d21..f98fdd4e159 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -18,10 +18,12 @@ module API
# Examples:
# GET /projects/:id/repository/commits/:sha/statuses
get ':id/repository/commits/:sha/statuses' do
- authorize! :read_commit_status, user_project
- sha = params[:sha]
- ci_commit = user_project.ci_commit(sha)
- not_found! 'Commit' unless ci_commit
+ authorize!(:read_commit_status, user_project)
+
+ ci_commit = user_project.ci_commit(params[:sha])
+ not_found!('Commit') unless user_project.commit(params[:sha])
+ return [] unless ci_commit
+
statuses = ci_commit.statuses
statuses = statuses.latest unless parse_boolean(params[:all])
statuses = statuses.where(ref: params[:ref]) if params[:ref].present?