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
This commit is contained in:
parent
b83b4fbef9
commit
248b96d8a3
10 changed files with 736 additions and 17 deletions
|
@ -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}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue