Commit e505e397 authored by Furkan Ayhan's avatar Furkan Ayhan

Merge branch 'aw-fix-invalid-sha-for-local-includes' into 'master'

Fix error from invalid sha for local `include` files

See merge request gitlab-org/gitlab!81036
parents 4a5260d5 32fe7986
......@@ -33,6 +33,10 @@ module Gitlab
def fetch_local_content
context.project.repository.blob_data_at(context.sha, location)
rescue GRPC::InvalidArgument
errors.push("Sha #{context.sha} is not valid!")
nil
end
override :expand_context_attrs
......
......@@ -81,6 +81,16 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do
expect(local_file.valid?).to be_falsy
end
end
context 'when the given sha is not valid' do
let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' }
let(:sha) { ':' }
it 'returns false and adds an error message stating that included file does not exist' do
expect(local_file).not_to be_valid
expect(local_file.errors).to include("Sha #{sha} is not valid!")
end
end
end
describe '#content' 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