mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Use git diff-tree
for DiffFileTree
on diff pages (#33514)
Modify Diff View FileTree to show all files ## Changes * removes Show Status button on diff * uses `git diff-tree` to generate the file tree for the diff * doesn't reload the diff tree each time we load more files in the preview * selecting and unloaded file will keep loading until that file is loaded * removes `DiffFileList.vue` and "Show Stats" in diff options ## Open Questions * selecting and unloaded file will keep loading until that file is loaded. Is this behaviour okay? It matches what github does. ### Demo In this demo I set `git.MAX_GIT_DIFF_FILES=1` in my `app.ini` to demonstrate a worst case example. In most cases the behaviour isn't nearly as jarring as we load a bunch of files at a time. https://github.com/user-attachments/assets/72f29663-d6fc-472d-94fa-7fb5950c2836 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -57,32 +57,6 @@
|
||||
<div>{{ctx.Locale.Tr "repo.pulls.showing_specified_commit_range" (ShortSha .BeforeCommitID) (ShortSha .AfterCommitID)}} - <a href="{{$.Issue.Link}}/files?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}">{{ctx.Locale.Tr "repo.pulls.show_all_commits"}}</a></div>
|
||||
</div>
|
||||
{{end}}
|
||||
<script id="diff-data-script" type="module">
|
||||
const diffDataFiles = [{{range $i, $file := .Diff.Files}}{Name:"{{$file.Name}}",NameHash:"{{$file.NameHash}}",Type:{{$file.Type}},IsBin:{{$file.IsBin}},IsSubmodule:{{$file.IsSubmodule}},Addition:{{$file.Addition}},Deletion:{{$file.Deletion}},IsViewed:{{$file.IsViewed}}},{{end}}];
|
||||
const diffData = {
|
||||
isIncomplete: {{.Diff.IsIncomplete}},
|
||||
tooManyFilesMessage: "{{ctx.Locale.Tr "repo.diff.too_many_files"}}",
|
||||
binaryFileMessage: "{{ctx.Locale.Tr "repo.diff.bin"}}",
|
||||
showMoreMessage: "{{ctx.Locale.Tr "repo.diff.show_more"}}",
|
||||
statisticsMessage: "{{ctx.Locale.Tr "repo.diff.stats_desc_file"}}",
|
||||
linkLoadMore: "?skip-to={{.Diff.End}}&file-only=true",
|
||||
};
|
||||
|
||||
// for first time loading, the diffFileInfo is a plain object
|
||||
// after the Vue component is mounted, the diffFileInfo is a reactive object
|
||||
// keep in mind that this script block would be executed many times when loading more files, by "loadMoreFiles"
|
||||
let diffFileInfo = window.config.pageData.diffFileInfo || {
|
||||
files:[],
|
||||
fileTreeIsVisible: false,
|
||||
fileListIsVisible: false,
|
||||
isLoadingNewData: false,
|
||||
selectedItem: '',
|
||||
};
|
||||
diffFileInfo = Object.assign(diffFileInfo, diffData);
|
||||
diffFileInfo.files.push(...diffDataFiles);
|
||||
window.config.pageData.diffFileInfo = diffFileInfo;
|
||||
</script>
|
||||
<div id="diff-file-list"></div>
|
||||
{{end}}
|
||||
<div id="diff-container">
|
||||
{{if $showFileTree}}
|
||||
|
Reference in New Issue
Block a user