Commit d5227355 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Merge branch '349975-fix-pipeline-editor-error' into 'master'

Handle Gitaly error on fetching total-branches for pipeline editor

See merge request gitlab-org/gitlab!80467
parents 8e1eb0d2 b7bbef2f
...@@ -12,6 +12,8 @@ module Ci ...@@ -12,6 +12,8 @@ module Ci
initial_branch = params[:branch_name] initial_branch = params[:branch_name]
latest_commit = project.repository.commit(initial_branch) || project.commit latest_commit = project.repository.commit(initial_branch) || project.commit
commit_sha = latest_commit ? latest_commit.sha : '' commit_sha = latest_commit ? latest_commit.sha : ''
total_branches = project.repository_exists? ? project.repository.branch_count : 0
{ {
"ci-config-path": project.ci_config_path_or_default, "ci-config-path": project.ci_config_path_or_default,
"ci-examples-help-page-path" => help_page_path('ci/examples/index'), "ci-examples-help-page-path" => help_page_path('ci/examples/index'),
...@@ -29,7 +31,7 @@ module Ci ...@@ -29,7 +31,7 @@ module Ci
"project-full-path" => project.full_path, "project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path, "project-namespace" => project.namespace.full_path,
"runner-help-page-path" => help_page_path('ci/runners/index'), "runner-help-page-path" => help_page_path('ci/runners/index'),
"total-branches" => project.repository.branches.length, "total-branches" => total_branches,
"yml-help-page-path" => help_page_path('ci/yaml/index') "yml-help-page-path" => help_page_path('ci/yaml/index')
} }
end end
......
...@@ -88,6 +88,17 @@ RSpec.describe Ci::PipelineEditorHelper do ...@@ -88,6 +88,17 @@ RSpec.describe Ci::PipelineEditorHelper do
end end
end end
context 'with a project with no repository' do
let(:project) { create(:project) }
it 'returns pipeline editor data' do
expect(pipeline_editor_data).to include({
"pipeline_etag" => '',
"total-branches" => 0
})
end
end
context 'with a non-default branch name' do context 'with a non-default branch name' do
let(:user) { create(:user) } let(:user) { create(:user) }
......
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