Commit 94c7a93d authored by Nick Thomas's avatar Nick Thomas

Merge branch 'fix/commits-api-empty-refname' into 'master'

fix handling of empty ref_name parameter string in commits api

Closes #64745

See merge request gitlab-org/gitlab-ce!31687
parents 648e5a94 eb357282
---
title: Fix 500 errors in commits api caused by empty ref_name parameter
merge_request:
author:
type: fixed
......@@ -43,7 +43,7 @@ module API
path = params[:path]
before = params[:until]
after = params[:since]
ref = params[:ref_name] || user_project.try(:default_branch) || 'master' unless params[:all]
ref = params[:ref_name].presence || user_project.try(:default_branch) || 'master' unless params[:all]
offset = (params[:page] - 1) * params[:per_page]
all = params[:all]
with_stats = params[:with_stats]
......
......@@ -126,6 +126,12 @@ describe API::Commits do
end
end
context "with empty ref_name parameter" do
let(:route) { "/projects/#{project_id}/repository/commits?ref_name=" }
it_behaves_like 'project commits'
end
context "path optional parameter" do
it "returns project commits matching provided path parameter" do
path = 'files/ruby/popen.rb'
......
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