1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Comments will be shown at the right place now

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz
2018-05-14 14:05:38 +02:00
parent ed695c1bf9
commit de7081c2ab
7 changed files with 50 additions and 31 deletions

View File

@@ -345,11 +345,7 @@ func (c *Comment) getPathAndFile(repoPath string) (string, string) {
func (c *Comment) checkInvalidation(e Engine, repo *git.Repository, branch string) error {
p, file := c.getPathAndFile(repo.Path)
// FIXME differentiate between previous and proposed line
var line = c.Line
if line < 0 {
line *= -1
}
commit, err := repo.LineBlame(branch, p, file, uint(line))
commit, err := repo.LineBlame(branch, p, file, uint(c.UnsignedLine()))
if err != nil {
return err
}
@@ -366,6 +362,22 @@ func (c *Comment) CheckInvalidation(repo *git.Repository, branch string) error {
return c.checkInvalidation(x, repo, branch)
}
// DiffSide returns "previous" if Comment.Line is a LOC of the previous changes and "proposed" if it is a LOC of the proposed changes.
func (c *Comment) DiffSide() string {
if c.Line < 0 {
return "previous"
}
return "proposed"
}
// UnsignedLine returns the LOC of the code comment without + or -
func (c *Comment) UnsignedLine() uint64 {
if c.Line < 0 {
return uint64(c.Line * -1)
}
return uint64(c.Line)
}
func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
var LabelID int64
if opts.Label != nil {