diff options
author | zeripath <art27@cantab.net> | 2021-09-09 21:13:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 21:13:36 +0100 |
commit | 248b96d8a38b2d52a73d7091a82f688f4688295e (patch) | |
tree | 43dfd0341cfbd86d576c1de073f8ad060f84b60b /templates/repo/diff | |
parent | b83b4fbef9df7bb4beef5684b18fe2ef210c42a2 (diff) | |
download | gitea-248b96d8a38b2d52a73d7091a82f688f4688295e.tar.gz gitea-248b96d8a38b2d52a73d7091a82f688f4688295e.zip |
Use git attributes to determine generated and vendored status for language stats and diffs (#16773)
Replaces #16262
Replaces #16250
Replaces #14833
This PR first implements a `git check-attr` pipe reader - using `git check-attr --stdin -z --cached` - taking account of the change in the output format in git 1.8.5 and creates a helper function to read a tree into a temporary index file for that pipe reader.
It then wires this in to the language stats helper and into the git diff generation.
Files which are marked generated will be folded by default.
Fixes #14786
Fixes #12653
Diffstat (limited to 'templates/repo/diff')
-rw-r--r-- | templates/repo/diff/box.tmpl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 4f8f726097..8c4b972bbc 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -49,11 +49,15 @@ {{$isImage := or (call $.IsBlobAnImage $blobBase) (call $.IsBlobAnImage $blobHead)}} {{$isCsv := (call $.IsCsvFile $file)}} {{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}} - <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} mt-3" id="diff-{{.Index}}"> + <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} mt-3" id="diff-{{.Index}}" {{if $file.IsGenerated}}data-folded="true"{{end}}> <h4 class="diff-file-header sticky-2nd-row ui top attached normal header df ac sb"> - <div class="df ac"> - <a role="button" class="fold-file muted mr-2"> - {{svg "octicon-chevron-down" 18}} + <div class="fold-file df ac"> + <a role="button" class="chevron muted mr-2"> + {{if $file.IsGenerated}} + {{svg "octicon-chevron-right" 18}} + {{else}} + {{svg "octicon-chevron-down" 18}} + {{end}} </a> <div class="bold df ac"> {{if $file.IsBin}} @@ -65,6 +69,12 @@ {{end}} </div> <span class="file mono">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span> + {{if $file.IsGenerated}} + <span class="ui label ml-3">{{$.i18n.Tr "repo.diff.generated"}}</span> + {{end}} + {{if $file.IsVendored}} + <span class="ui label ml-3">{{$.i18n.Tr "repo.diff.vendored"}}</span> + {{end}} </div> <div class="diff-file-header-actions df ac"> {{if $showFileViewToggle}} |