From a65f0f697040b6ec09f17713c7ab9239d725abd7 Mon Sep 17 00:00:00 2001 From: abhishek818 Date: Mon, 14 Oct 2024 23:50:59 +0530 Subject: [PATCH] allow comments on non-diff lines (#32257) Signed-off-by: abhishek818 --- services/gitdiff/gitdiff.go | 2 +- services/gitdiff/gitdiff_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 0ddd5a48e2148..83d83affbfa4c 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -118,7 +118,7 @@ func (d *DiffLine) GetHTMLDiffLineType() string { // CanComment returns whether a line can get commented func (d *DiffLine) CanComment() bool { - return len(d.Comments) == 0 && d.Type != DiffLineSection + return len(d.Comments) == 0 } // GetCommentSide returns the comment side of the first comment, if not set returns empty string diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index adcac355a7bb4..644c2475f40ac 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -615,7 +615,7 @@ func TestDiff_LoadCommentsWithOutdated(t *testing.T) { } func TestDiffLine_CanComment(t *testing.T) { - assert.False(t, (&DiffLine{Type: DiffLineSection}).CanComment()) + assert.True(t, (&DiffLine{Type: DiffLineSection}).CanComment()) assert.False(t, (&DiffLine{Type: DiffLineAdd, Comments: []*issues_model.Comment{{Content: "bla"}}}).CanComment()) assert.True(t, (&DiffLine{Type: DiffLineAdd}).CanComment()) assert.True(t, (&DiffLine{Type: DiffLineDel}).CanComment())