Commit 458553d0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '322096-fj-fix-regression-in-snippet-background-migration' into 'master'

Fix snippet commit bug because of different Gitaly error

See merge request gitlab-org/gitlab!54662
parents cb5ba178 b3faaa9c
...@@ -115,8 +115,10 @@ class SnippetRepository < ApplicationRecord ...@@ -115,8 +115,10 @@ class SnippetRepository < ApplicationRecord
end end
def invalid_path_error?(err) def invalid_path_error?(err)
err.is_a?(Gitlab::Git::Index::IndexError) && (err.is_a?(Gitlab::Git::Index::IndexError) &&
err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal') err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal')) ||
(err.is_a?(Gitlab::Git::CommandError) &&
err.message.include?('CreateFile: invalid path'))
end end
def invalid_signature_error?(err) def invalid_signature_error?(err)
......
---
title: Fix snippet commit bug because of different Gitaly error
merge_request: 54662
author:
type: fixed
...@@ -286,6 +286,7 @@ RSpec.describe SnippetRepository do ...@@ -286,6 +286,7 @@ RSpec.describe SnippetRepository do
context 'with git errors' do context 'with git errors' do
it_behaves_like 'snippet repository with git errors', 'invalid://path/here', described_class::InvalidPathError it_behaves_like 'snippet repository with git errors', 'invalid://path/here', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', '.git/hooks/pre-commit', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', '../../path/traversal/here', described_class::InvalidPathError it_behaves_like 'snippet repository with git errors', '../../path/traversal/here', described_class::InvalidPathError
it_behaves_like 'snippet repository with git errors', 'README', described_class::CommitError it_behaves_like 'snippet repository with git errors', 'README', described_class::CommitError
......
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