Use case-insensitive matching for Git error "Not a valid object name" (#36728)

Fixes #36727

Git is lowercasing the `fatal: Not a valid object name` error message
to follow its CodingGuidelines. This change makes the string matching
case-insensitive so it works with both the current and future Git
versions.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Md Ferdous Alam
2026-02-24 10:25:34 +06:00
committed by GitHub
parent a8505269ca
commit 429ba9c010
5 changed files with 22 additions and 10 deletions

View File

@@ -77,6 +77,13 @@ func IsErrorCanceledOrKilled(err error) bool {
return errors.Is(err, context.Canceled) || IsErrorSignalKilled(err)
}
func IsStdErrorNotValidObjectName(err error) bool {
stderr, ok := ErrorAsStderr(err)
// Git is lowercasing the "fatal: Not a valid object name" error message
// ref: https://lore.kernel.org/git/pull.2052.git.1771836302101.gitgitgadget@gmail.com
return ok && strings.Contains(strings.ToLower(stderr), "fatal: not a valid object name")
}
type pipelineError struct {
error
}