mirror of
https://github.com/go-gitea/gitea
synced 2025-01-19 01:17:43 +01:00
chore: remove the add comment on the line section. fix the hsaComments logic
This commit is contained in:
parent
649201dafc
commit
50bab1b24b
@ -956,8 +956,8 @@ func ExcerptBlob(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
lineCommits := allComments[filePath]
|
lineCommits := allComments[filePath]
|
||||||
for _, line := range section.Lines {
|
for index, line := range section.Lines {
|
||||||
if line.SectionInfo != nil && line.SectionInfo.RightHunkSize > 0 {
|
if line.SectionInfo != nil && line.Type == 4 && !(line.SectionInfo.LastRightIdx == 0 && index+1 == len(section.Lines)) {
|
||||||
start := int64(line.SectionInfo.LastRightIdx + 1)
|
start := int64(line.SectionInfo.LastRightIdx + 1)
|
||||||
end := int64(line.SectionInfo.RightIdx - 1)
|
end := int64(line.SectionInfo.RightIdx - 1)
|
||||||
for start <= end {
|
for start <= end {
|
||||||
|
@ -121,7 +121,7 @@ func (d *DiffLine) GetHTMLDiffLineType() string {
|
|||||||
|
|
||||||
// CanComment returns whether a line can get commented
|
// CanComment returns whether a line can get commented
|
||||||
func (d *DiffLine) CanComment() bool {
|
func (d *DiffLine) CanComment() bool {
|
||||||
return len(d.Comments) == 0
|
return len(d.Comments) == 0 && d.Type != DiffLineSection
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommentSide returns the comment side of the first comment, if not set returns empty string
|
// GetCommentSide returns the comment side of the first comment, if not set returns empty string
|
||||||
@ -481,8 +481,8 @@ func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, c
|
|||||||
for _, file := range diff.Files {
|
for _, file := range diff.Files {
|
||||||
if lineCommits, ok := allComments[file.Name]; ok {
|
if lineCommits, ok := allComments[file.Name]; ok {
|
||||||
for _, section := range file.Sections {
|
for _, section := range file.Sections {
|
||||||
for _, line := range section.Lines {
|
for index, line := range section.Lines {
|
||||||
if line.SectionInfo != nil && line.SectionInfo.RightHunkSize > 0 {
|
if line.SectionInfo != nil && line.Type == 4 && !(line.SectionInfo.LastRightIdx == 0 && index+1 == len(section.Lines)) {
|
||||||
start := int64(line.SectionInfo.LastRightIdx + 1)
|
start := int64(line.SectionInfo.LastRightIdx + 1)
|
||||||
end := int64(line.SectionInfo.RightIdx - 1)
|
end := int64(line.SectionInfo.RightIdx - 1)
|
||||||
for start <= end {
|
for start <= end {
|
||||||
|
@ -615,7 +615,7 @@ func TestDiff_LoadCommentsWithOutdated(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDiffLine_CanComment(t *testing.T) {
|
func TestDiffLine_CanComment(t *testing.T) {
|
||||||
assert.True(t, (&DiffLine{Type: DiffLineSection}).CanComment())
|
assert.False(t, (&DiffLine{Type: DiffLineSection}).CanComment())
|
||||||
assert.False(t, (&DiffLine{Type: DiffLineAdd, Comments: []*issues_model.Comment{{Content: "bla"}}}).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: DiffLineAdd}).CanComment())
|
||||||
assert.True(t, (&DiffLine{Type: DiffLineDel}).CanComment())
|
assert.True(t, (&DiffLine{Type: DiffLineDel}).CanComment())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user