mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-02 06:57:15 +01:00
chore: remove issue index and minro template changes
This commit is contained in:
parent
ccd797abee
commit
efba6c4a2d
@ -865,7 +865,6 @@ func ExcerptBlob(ctx *context.Context) {
|
||||
direction := ctx.FormString("direction")
|
||||
filePath := ctx.FormString("path")
|
||||
gitRepo := ctx.Repo.GitRepo
|
||||
fileName := ctx.FormString("file_name")
|
||||
if ctx.FormBool("pull") {
|
||||
ctx.Data["PageIsPullFiles"] = true
|
||||
}
|
||||
@ -879,17 +878,6 @@ func ExcerptBlob(ctx *context.Context) {
|
||||
}
|
||||
defer gitRepo.Close()
|
||||
}
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, int64(2))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
return
|
||||
}
|
||||
allComments, err := issues_model.FetchCodeComments(ctx, issue, ctx.Doer, false)
|
||||
if err != nil {
|
||||
ctx.ServerError("FetchCodeComments", err)
|
||||
return
|
||||
}
|
||||
lineCommits := allComments[fileName]
|
||||
chunkSize := gitdiff.BlobExcerptChunkSize
|
||||
commit, err := gitRepo.GetCommit(commitID)
|
||||
if err != nil {
|
||||
@ -955,45 +943,59 @@ func ExcerptBlob(ctx *context.Context) {
|
||||
section.Lines = append(section.Lines, lineSection)
|
||||
}
|
||||
}
|
||||
for _, line := range section.Lines {
|
||||
if line.SectionInfo != nil {
|
||||
start := int64(line.SectionInfo.LastRightIdx + 1)
|
||||
end := int64(line.SectionInfo.RightIdx - 1)
|
||||
for start <= end {
|
||||
if _, ok := lineCommits[start]; ok {
|
||||
if !line.SectionInfo.HasComments {
|
||||
line.SectionInfo.HasComments = true
|
||||
break
|
||||
issueIndex := ctx.FormInt64("issue_index")
|
||||
if ctx.FormBool("pull") && issueIndex > 0 {
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
|
||||
if issue == nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
return
|
||||
}
|
||||
allComments, err := issues_model.FetchCodeComments(ctx, issue, ctx.Doer, false)
|
||||
if err != nil {
|
||||
ctx.ServerError("FetchCodeComments", err)
|
||||
return
|
||||
}
|
||||
lineCommits := allComments[filePath]
|
||||
for _, line := range section.Lines {
|
||||
if line.SectionInfo != nil {
|
||||
start := int64(line.SectionInfo.LastRightIdx + 1)
|
||||
end := int64(line.SectionInfo.RightIdx - 1)
|
||||
for start <= end {
|
||||
if _, ok := lineCommits[start]; ok {
|
||||
if !line.SectionInfo.HasComments {
|
||||
line.SectionInfo.HasComments = true
|
||||
break
|
||||
}
|
||||
}
|
||||
start++
|
||||
}
|
||||
start++
|
||||
}
|
||||
}
|
||||
if comments, ok := lineCommits[int64(line.LeftIdx*-1)]; ok {
|
||||
line.Comments = append(line.Comments, comments...)
|
||||
}
|
||||
if comments, ok := lineCommits[int64(line.RightIdx)]; ok {
|
||||
line.Comments = append(line.Comments, comments...)
|
||||
}
|
||||
if comments, ok := lineCommits[int64(line.LeftIdx*-1)]; ok {
|
||||
line.Comments = append(line.Comments, comments...)
|
||||
}
|
||||
if comments, ok := lineCommits[int64(line.RightIdx)]; ok {
|
||||
line.Comments = append(line.Comments, comments...)
|
||||
}
|
||||
|
||||
sort.SliceStable(line.Comments, func(i, j int) bool {
|
||||
return line.Comments[i].CreatedUnix < line.Comments[j].CreatedUnix
|
||||
})
|
||||
}
|
||||
for _, line := range section.Lines {
|
||||
for _, comment := range line.Comments {
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
return
|
||||
sort.SliceStable(line.Comments, func(i, j int) bool {
|
||||
return line.Comments[i].CreatedUnix < line.Comments[j].CreatedUnix
|
||||
})
|
||||
}
|
||||
for _, line := range section.Lines {
|
||||
for _, comment := range line.Comments {
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.Data["Issue"] = issue
|
||||
ctx.Data["IssueIndex"] = issue.Index
|
||||
}
|
||||
ctx.Data["section"] = section
|
||||
ctx.Data["FileNameHash"] = git.HashFilePathForWebUI(filePath)
|
||||
ctx.Data["AfterCommitID"] = commitID
|
||||
ctx.Data["Anchor"] = anchor
|
||||
ctx.Data["Issue"] = issue
|
||||
ctx.Data["issue"] = issue.Index
|
||||
ctx.Data["CanBlockUser"] = func(blocker, blockee *user_model.User) bool {
|
||||
return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee)
|
||||
}
|
||||
|
||||
@ -128,6 +128,7 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
|
||||
}
|
||||
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, emoji.ReplaceAliases(issue.Title))
|
||||
ctx.Data["Issue"] = issue
|
||||
ctx.Data["IssueIndex"] = issue.Index
|
||||
|
||||
if !issue.IsPull {
|
||||
ctx.NotFound("ViewPullCommits", nil)
|
||||
|
||||
@ -15,17 +15,17 @@
|
||||
</div>
|
||||
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold-down"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold-up"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if eq $expandDirection 2}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}&file_name={{$.section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}&pull={{$.PageIsPullFiles}}&anchor={{$.Anchor}}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold"}}
|
||||
</button>
|
||||
{{end}}
|
||||
@ -88,17 +88,17 @@
|
||||
</div>
|
||||
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
|
||||
<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}}">
|
||||
<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}}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold-down"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
|
||||
<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}}">
|
||||
<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}}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold-up"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if eq $expandDirection 2}}
|
||||
<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}}">
|
||||
<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}}}&issue_index={{$.IssueIndex}}">
|
||||
{{svg "octicon-fold"}}
|
||||
</button>
|
||||
{{end}}
|
||||
@ -117,9 +117,7 @@
|
||||
{{svg "octicon-plus"}}
|
||||
</button>
|
||||
{{end}}
|
||||
<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"{{else}}class="code-inner"{{end}}>
|
||||
{{$inlineDiff.Content}}
|
||||
</code>
|
||||
<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>
|
||||
</td>
|
||||
</tr>
|
||||
{{if $line.Comments}}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{{$file := .file}}
|
||||
{{$blobExcerptRepoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
|
||||
{{$issueIndex := or ctx.RootData.IssueIndex $.root.IssueIndex}}
|
||||
<colgroup>
|
||||
<col width="50">
|
||||
<col width="10">
|
||||
@ -28,17 +29,17 @@
|
||||
</div>
|
||||
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold-down"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold-up"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if eq $expandDirection 2}}
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&file_name={{$section.FileName}}">
|
||||
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&pull={{$.root.PageIsPullFiles}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold"}}
|
||||
</button>
|
||||
{{end}}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{{$file := .file}}
|
||||
{{$blobExcerptRepoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
|
||||
{{$issueIndex := or ctx.RootData.IssueIndex $.root.IssueIndex}}
|
||||
<colgroup>
|
||||
<col width="50">
|
||||
<col width="50">
|
||||
@ -24,17 +25,17 @@
|
||||
</div>
|
||||
<div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
|
||||
<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}}">
|
||||
<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}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold-down"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
|
||||
<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}}">
|
||||
<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}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold-up"}}
|
||||
</button>
|
||||
{{end}}
|
||||
{{if eq $expandDirection 2}}
|
||||
<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}}">
|
||||
<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}}&issue_index={{$issueIndex}}">
|
||||
{{svg "octicon-fold"}}
|
||||
</button>
|
||||
{{end}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user