diff options
author | Lauris BH <lauris@nix.lv> | 2018-09-17 17:59:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 17:59:49 +0300 |
commit | 4befec242aa3563f5a8a38bd390d834e4aa2797b (patch) | |
tree | f372612f3911ceb304bc6868b051a4c972025013 /models/issue_comment.go | |
parent | 756eafaaf68b3cadb3f33f37554a6aa2d83921ef (diff) | |
download | gitea-4befec242aa3563f5a8a38bd390d834e4aa2797b.tar.gz gitea-4befec242aa3563f5a8a38bd390d834e4aa2797b.zip |
Code review UI improvements and bugfixes (#4682)
* Code review UI improvements
* More fixes to dark theme
* Style fix
* Fix to allow add code review comments only on review files tab
* More readability dark style fixes
* Fix commenting on deleted files. Fixes #4752
* Fix line blame getting for multiple corner cases
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r-- | models/issue_comment.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go index 8cbd9613a0..eb185a7662 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -392,7 +392,7 @@ func (c *Comment) checkInvalidation(e Engine, doer *User, repo *git.Repository, if err != nil { return err } - if c.CommitSHA != commit.ID.String() { + if c.CommitSHA != "" && c.CommitSHA != commit.ID.String() { c.Invalidated = true return UpdateComment(doer, c, "") } @@ -824,17 +824,18 @@ func CreateCodeComment(doer *User, repo *Repository, issue *Issue, content, tree if err != nil { return nil, fmt.Errorf("OpenRepository: %v", err) } - // FIXME differentiate between previous and proposed line - var gitLine = line - if gitLine < 0 { - gitLine *= -1 - } + // FIXME validate treePath // Get latest commit referencing the commented line - commit, err := gitRepo.LineBlame(pr.GetGitRefName(), gitRepo.Path, treePath, uint(gitLine)) - if err != nil { - return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %v", pr.GetGitRefName(), gitRepo.Path, treePath, gitLine, err) + // No need for get commit for base branch changes + if line > 0 { + commit, err := gitRepo.LineBlame(pr.GetGitRefName(), gitRepo.Path, treePath, uint(line)) + if err != nil { + return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %v", pr.GetGitRefName(), gitRepo.Path, treePath, line, err) + } + commitID = commit.ID.String() } + // Only fetch diff if comment is review comment if reviewID != 0 { headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName()) @@ -846,7 +847,6 @@ func CreateCodeComment(doer *User, repo *Repository, issue *Issue, content, tree return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", err, gitRepo.Path, pr.MergeBase, headCommitID, treePath) } patch = CutDiffAroundLine(strings.NewReader(patchBuf.String()), int64((&Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines) - commitID = commit.ID.String() } return CreateComment(&CreateCommentOptions{ Type: CommentTypeCode, |