Skip to content

Commit ed80303

Browse files
chore: fix lint issues
chore: removed unwanted code chore: lint issues
1 parent 914bed8 commit ed80303

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed

routers/web/repo/compare.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,6 @@ func ExcerptBlob(ctx *context.Context) {
868868
lastRightCommentIdx := ctx.FormInt("last_left_comment_idx")
869869
rightCommentIdx := ctx.FormInt("left_comment_idx")
870870
fileName := ctx.FormString("file_name")
871-
872871
if ctx.FormBool("pull") {
873872
ctx.Data["PageIsPullFiles"] = true
874873
}
@@ -891,6 +890,10 @@ func ExcerptBlob(ctx *context.Context) {
891890
}
892891

893892
allComments, err := issues_model.FetchCodeComments(ctx, issue, ctx.Doer, false)
893+
if err != nil {
894+
ctx.ServerError("FetchCodeComments", err)
895+
return
896+
}
894897
lineCommits := allComments[fileName]
895898

896899
chunkSize := gitdiff.BlobExcerptChunkSize
@@ -958,30 +961,19 @@ func ExcerptBlob(ctx *context.Context) {
958961
section.Lines = append(section.Lines, lineSection)
959962
}
960963
}
961-
962964
for _, line := range section.Lines {
963965
if line.SectionInfo != nil {
964-
//for now considerign only right side.
965966
start := int64(line.SectionInfo.LastRightIdx + 1)
966967
end := int64(line.SectionInfo.RightIdx - 1)
967-
968-
//to check section has comments or not.
969-
//1. we can use binary search
970-
//2. we can LastRightCommentIdx, RightCommentIdx, LastLeftCommentIdx, LeftCommentIdx(little complex but fast)
971-
//3. for demo using linear search
972968
for start <= end {
973969
if _, ok := lineCommits[start]; ok {
974970
if !line.SectionInfo.HasComments {
975-
// line.SectionInfo.LastRightCommentIdx = int(start)
976-
// line.SectionInfo.RightCommentIdx = int(start)
977971
line.SectionInfo.HasComments = true
978972
break
979973
}
980-
981974
}
982-
start += 1
975+
start++
983976
}
984-
985977
}
986978
if comments, ok := lineCommits[int64(line.LeftIdx*-1)]; ok {
987979
line.Comments = append(line.Comments, comments...)
@@ -994,7 +986,6 @@ func ExcerptBlob(ctx *context.Context) {
994986
return line.Comments[i].CreatedUnix < line.Comments[j].CreatedUnix
995987
})
996988
}
997-
998989
for _, line := range section.Lines {
999990
for _, comment := range line.Comments {
1000991
if err := comment.LoadAttachments(ctx); err != nil {
@@ -1003,18 +994,15 @@ func ExcerptBlob(ctx *context.Context) {
1003994
}
1004995
}
1005996
}
1006-
1007997
ctx.Data["section"] = section
1008998
ctx.Data["FileNameHash"] = git.HashFilePathForWebUI(filePath)
1009999
ctx.Data["AfterCommitID"] = commitID
10101000
ctx.Data["Anchor"] = anchor
10111001
ctx.Data["Issue"] = issue
10121002
ctx.Data["issue"] = issue.Index
1013-
ctx.Data["SignedUserID"] = ctx.Data["SignedUserID"]
10141003
ctx.Data["CanBlockUser"] = func(blocker, blockee *user_model.User) bool {
10151004
return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee)
10161005
}
1017-
10181006
if ctx.Data["SignedUserID"] == nil {
10191007
ctx.Data["SignedUserID"] = ctx.Doer.ID
10201008
}

services/gitdiff/gitdiff.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,20 +485,14 @@ func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, c
485485
if line.SectionInfo != nil {
486486
start := int64(line.SectionInfo.LastRightIdx + 1)
487487
end := int64(line.SectionInfo.RightIdx - 1)
488-
489488
for start <= end {
490489
if _, ok := lineCommits[start]; ok {
491-
if line.SectionInfo.LastRightCommentIdx == 0 {
492-
// line.SectionInfo.LastRightCommentIdx = int(start)
493-
// line.SectionInfo.RightCommentIdx = int(start)
490+
if !line.SectionInfo.HasComments {
494491
line.SectionInfo.HasComments = true
495-
496492
break
497493
}
498-
499494
}
500-
start += 1
501-
495+
start++
502496
}
503497
}
504498
if comments, ok := lineCommits[int64(line.LeftIdx*-1)]; ok {

templates/repo/diff/blob_excerpt.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,16 @@
9191
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
9292
{{svg "octicon-fold-down"}}
9393
</button>
94-
test else down blob {{$line.SectionInfo.HasComments}}
9594
{{end}}
9695
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
9796
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
9897
{{svg "octicon-fold-up"}}
9998
</button>
100-
test else up blob
10199
{{end}}
102100
{{if eq $expandDirection 2}}
103101
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
104102
{{svg "octicon-fold"}}
105103
</button>
106-
test else both blob
107104
{{end}}
108105
</div>
109106
</div>

templates/repo/diff/section_unified.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@
2727
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
2828
{{svg "octicon-fold-down"}}
2929
</button>
30-
test down
3130
{{end}}
3231
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
3332
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
3433
{{svg "octicon-fold-up"}}
3534
</button>
36-
test up
3735
{{end}}
3836
{{if eq $expandDirection 2}}
3937
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
4038
{{svg "octicon-fold"}}
4139
</button>
42-
test fold
4340
{{end}}
4441
</div>
4542
</div>

0 commit comments

Comments
 (0)