Add max file limit in diffs
2398e298457e7966c63006bf7723da47d26db75e
1 parent
d288f66a
git.go
+1 -0
| 89 | 89 | IsActive bool |
|
| 90 | 90 | } |
|
| 91 | 91 | ||
| 92 | 92 | const maxBlobDisplaySize = 1 << 20 // 1MB |
|
| 93 | 93 | const diffContextLines = 5 |
|
| 94 | + | const maxDiffFiles = 256 // max files rendered per commit |
|
| 94 | 95 | ||
| 95 | 96 | func sortTreeEntries(entries []TreeEntryInfo) { |
|
| 96 | 97 | sort.Slice(entries, func(i, j int) bool { |
|
| 97 | 98 | if entries[i].IsDir != entries[j].IsDir { |
|
| 98 | 99 | return entries[i].IsDir |
handler.go
+12 -4
| 279 | 279 | s.renderHome(w, repo, ref, nil, path) |
|
| 280 | 280 | } |
|
| 281 | 281 | ||
| 282 | 282 | func (s *server) handleCommit(w http.ResponseWriter, r *http.Request, repo *RepoInfo, rest string) { |
|
| 283 | 283 | type commitData struct { |
|
| 284 | - | Commit *CommitInfo |
|
| 285 | - | Files []DiffFile |
|
| 284 | + | Commit *CommitInfo |
|
| 285 | + | Files []DiffFile |
|
| 286 | + | TruncatedFiles int |
|
| 286 | 287 | } |
|
| 287 | 288 | ||
| 288 | 289 | git := repo.Git |
|
| 289 | 290 | commit, err := git.getCommit(rest) |
|
| 290 | 291 | if err != nil { |
| 296 | 297 | if err != nil { |
|
| 297 | 298 | s.renderError(w, r, http.StatusInternalServerError, err.Error()) |
|
| 298 | 299 | return |
|
| 299 | 300 | } |
|
| 300 | 301 | ||
| 302 | + | var truncatedFiles int |
|
| 303 | + | if len(files) > maxDiffFiles { |
|
| 304 | + | truncatedFiles = len(files) - maxDiffFiles |
|
| 305 | + | files = files[:maxDiffFiles] |
|
| 306 | + | } |
|
| 307 | + | ||
| 301 | 308 | pd := s.newPageData(repo, "commit", "") |
|
| 302 | 309 | pd.CommitHash = commit.Hash |
|
| 303 | 310 | pd.Data = commitData{ |
|
| 304 | - | Commit: commit, |
|
| 305 | - | Files: files, |
|
| 311 | + | Commit: commit, |
|
| 312 | + | Files: files, |
|
| 313 | + | TruncatedFiles: truncatedFiles, |
|
| 306 | 314 | } |
|
| 307 | 315 | s.tmpl.render(w, "commit", pd) |
|
| 308 | 316 | } |
|
| 309 | 317 | ||
| 310 | 318 | func (s *server) handleRefs(w http.ResponseWriter, r *http.Request, repo *RepoInfo) { |
templates/commit.html
+3 -0
| 41 | 41 | </table> |
|
| 42 | 42 | {{end}} |
|
| 43 | 43 | {{end}} |
|
| 44 | 44 | </div> |
|
| 45 | 45 | {{end}} |
|
| 46 | + | {{if .Data.TruncatedFiles}} |
|
| 47 | + | <p class="empty">{{.Data.TruncatedFiles}} more file{{if ne .Data.TruncatedFiles 1}}s{{end}} not shown.</p> |
|
| 48 | + | {{end}} |
|
| 46 | 49 | {{end}} |