From 6ae32b27e381502203d6a5af0934e08e2ff464c3 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Mon, 14 May 2018 19:04:45 +0200 Subject: [PATCH] Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz --- models/issue_comment.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/models/issue_comment.go b/models/issue_comment.go index 79311c5aa1..3c9fa64bbe 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -6,7 +6,6 @@ package models import ( "fmt" - "path" "strings" "code.gitea.io/git" @@ -332,20 +331,9 @@ func (c *Comment) LoadReview() error { return c.loadReview(x) } -func (c *Comment) getPathAndFile(repoPath string) (string, string) { - p := path.Dir(c.TreePath) - if p == "." { - p = "" - } - p = fmt.Sprintf("%s/%s", repoPath, p) - file := path.Base(c.TreePath) - return p, file -} - 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 - commit, err := repo.LineBlame(branch, p, file, uint(c.UnsignedLine())) + commit, err := repo.LineBlame(branch, repo.Path, c.TreePath, uint(c.UnsignedLine())) if err != nil { return err } @@ -673,14 +661,13 @@ func CreateCodeComment(doer *User, repo *Repository, issue *Issue, content, tree if err != nil { return nil, fmt.Errorf("OpenRepository: %v", err) } - dummyComment := &Comment{Line: line, TreePath: treePath} - p, file := dummyComment.getPathAndFile(gitRepo.Path) // FIXME differentiate between previous and proposed line var gitLine = line if gitLine < 0 { gitLine *= -1 } - commit, err := gitRepo.LineBlame(pr.HeadBranch, p, file, uint(gitLine)) + // FIXME validate treePath + commit, err := gitRepo.LineBlame(pr.HeadBranch, gitRepo.Path, treePath, uint(gitLine)) if err != nil { return nil, err }