fix: correct stdErr match in isErrBlameNotFoundOrNotEnoughLines (#39309)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Abhay Pratap Singh
2026-09-14 14:59:18 +00:00
committed by GitHub
co-authored by wxiaoguang
parent 13033827b1
commit 85cbf477e5
6 changed files with 73 additions and 59 deletions
+1 -8
View File
@@ -8,7 +8,6 @@ import (
"context"
"errors"
"fmt"
"strings"
"gitea.dev/models/db"
issues_model "gitea.dev/models/issues"
@@ -25,13 +24,7 @@ import (
)
func isErrBlameNotFoundOrNotEnoughLines(err error) bool {
stdErr, ok := gitcmd.ErrorAsStderr(err)
if !ok {
return false
}
notFound := strings.HasPrefix(stdErr, "fatal: no such path")
notEnoughLines := strings.HasPrefix(stdErr, "fatal: file ") && strings.Contains(stdErr, " has only ") && strings.Contains(stdErr, " lines?")
return notFound || notEnoughLines
return gitcmd.IsStderr(err, gitcmd.StderrNoSuchPath, gitcmd.StderrFileNoEnoughLines)
}
// ErrDismissRequestOnClosedPR represents an error when a user tries to dismiss a review associated to a closed or merged PR.