diff options
author | 6543 <6543@obermui.de> | 2020-10-06 02:18:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 20:18:55 -0400 |
commit | df4bbcd235cec8708cd0cbdd9bcbdd00f5db4fd5 (patch) | |
tree | f4eb221c496c6e3305712efccb0daa1f1af61687 /services | |
parent | b5e76dddb8051b6e11b0df7f73b7f883365385cf (diff) | |
download | gitea-df4bbcd235cec8708cd0cbdd9bcbdd00f5db4fd5.tar.gz gitea-df4bbcd235cec8708cd0cbdd9bcbdd00f5db4fd5.zip |
Fix error create comment on outdated file (#13041)
* FIX
* more specific
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services')
-rw-r--r-- | services/pull/review.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/services/pull/review.go b/services/pull/review.go index 5a77a4da16..09ab3ff567 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -8,6 +8,7 @@ package pull import ( "bytes" "fmt" + "regexp" "strings" "code.gitea.io/gitea/models" @@ -104,6 +105,8 @@ func CreateCodeComment(doer *models.User, gitRepo *git.Repository, issue *models return comment, nil } +var notEnoughLines = regexp.MustCompile(`exit status 128 - fatal: file .* has only \d+ lines?`) + // createCodeComment creates a plain code comment at the specified line / path func createCodeComment(doer *models.User, repo *models.Repository, issue *models.Issue, content, treePath string, line, reviewID int64) (*models.Comment, error) { var commitID, patch string @@ -127,7 +130,7 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models commit, err := gitRepo.LineBlame(pr.GetGitRefName(), gitRepo.Path, treePath, uint(line)) if err == nil { commitID = commit.ID.String() - } else if !strings.Contains(err.Error(), "exit status 128 - fatal: no such path") { + } else if !(strings.Contains(err.Error(), "exit status 128 - fatal: no such path") || notEnoughLines.MatchString(err.Error())) { return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %v", pr.GetGitRefName(), gitRepo.Path, treePath, line, err) } } |