mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-21 09:06:46 +09:00
1 parent
829b49c1ae
commit
5838cc8172
2 files changed
+9
-3
No files matched your search
@@ -93,6 +93,7 @@ const (
|
||||
StderrPathSpec StderrPrefix = "fatal: pathspec"
|
||||
StderrBadRevision StderrPrefix = "fatal: bad revision"
|
||||
StderrNoSuchPath StderrPrefix = "fatal: no such path"
|
||||
StderrBadObject StderrPrefix = "fatal: bad object "
|
||||
|
||||
StderrNoSuchRemote1 StderrPrefix = "fatal: no such remote" // git < 2.30, exit status 128
|
||||
StderrNoSuchRemote2 StderrPrefix = "error: no such remote" // git >= 2.30. exit status 2
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func isErrBlameNotFoundOrNotEnoughLines(err error) bool {
|
||||
return gitcmd.IsStderr(err, gitcmd.StderrNoSuchPath, gitcmd.StderrFileNoEnoughLines)
|
||||
return gitcmd.IsStderr(err, gitcmd.StderrNoSuchPath, gitcmd.StderrFileNoEnoughLines, gitcmd.StderrBadObject)
|
||||
}
|
||||
|
||||
// ErrDismissRequestOnClosedPR represents an error when a user tries to dismiss a review associated to a closed or merged PR.
|
||||
@@ -248,10 +248,15 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo
|
||||
// Get latest commit referencing the commented line
|
||||
// No need for get commit for base branch changes
|
||||
commit, err := lineBlame(ctx, pr.BaseRepo, gitRepo, head, treePath, uint(line))
|
||||
// A force push may have removed the review's stored commit.
|
||||
if err != nil && head != pr.GetGitHeadRefName() {
|
||||
head = pr.GetGitHeadRefName()
|
||||
commit, err = lineBlame(ctx, pr.BaseRepo, gitRepo, head, treePath, uint(line))
|
||||
}
|
||||
if err == nil {
|
||||
commitID = commit.ID.String()
|
||||
} else if !isErrBlameNotFoundOrNotEnoughLines(err) {
|
||||
return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %w", pr.GetGitHeadRefName(), gitRepo.LogString(), treePath, line, err)
|
||||
} else {
|
||||
log.Debug("LineBlame[%s, %s, %s, %d]: %v", head, gitRepo.LogString(), treePath, line, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user