Backport #11882 Fix #10686 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
fdc6287973
commit
6abb8d751c
|
@ -8,6 +8,7 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
@ -489,10 +490,12 @@ func (c *Comment) LoadReview() error {
|
||||||
return c.loadReview(x)
|
return c.loadReview(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notEnoughLines = regexp.MustCompile(`fatal: file .* has only \d+ lines?`)
|
||||||
|
|
||||||
func (c *Comment) checkInvalidation(doer *User, repo *git.Repository, branch string) error {
|
func (c *Comment) checkInvalidation(doer *User, repo *git.Repository, branch string) error {
|
||||||
// FIXME differentiate between previous and proposed line
|
// FIXME differentiate between previous and proposed line
|
||||||
commit, err := repo.LineBlame(branch, repo.Path, c.TreePath, uint(c.UnsignedLine()))
|
commit, err := repo.LineBlame(branch, repo.Path, c.TreePath, uint(c.UnsignedLine()))
|
||||||
if err != nil && strings.Contains(err.Error(), "fatal: no such path") {
|
if err != nil && (strings.Contains(err.Error(), "fatal: no such path") || notEnoughLines.MatchString(err.Error())) {
|
||||||
c.Invalidated = true
|
c.Invalidated = true
|
||||||
return UpdateComment(c, doer)
|
return UpdateComment(c, doer)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue