Commit 364da026 authored by Stan Hu's avatar Stan Hu

Restore original index error check for snippet commit check

The Rugged implementation of the `UserCommitFiles` RPC raised a
`Gitlab::Git::Index::IndexError` when an invalid file was written
(e.g. `.git/hooks/pre-commit`), but the Go implementation previously
swallowed the Git2Go equivalent error and raised a
`Gitlab::Git::CommandError` instead.

Now that https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3165 has
been merged, we partially revert the change in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54662 to check the
original error type.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/322096
parent c29e42fe
......@@ -115,10 +115,8 @@ class SnippetRepository < ApplicationRecord
end
def invalid_path_error?(err)
(err.is_a?(Gitlab::Git::Index::IndexError) &&
err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal')) ||
(err.is_a?(Gitlab::Git::CommandError) &&
err.message.include?('CreateFile: invalid path'))
err.is_a?(Gitlab::Git::Index::IndexError) &&
err.message.downcase.start_with?('invalid path', 'path cannot include directory traversal')
end
def invalid_signature_error?(err)
......
---
title: Fix snippet commit bug because of different Gitaly error
merge_request: 54662
author:
type: fixed
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