forgejo-aneksajo_auto_patch.../workspace/46/patched.diff

104 lines
3.5 KiB
Diff

36a37
> "code.gitea.io/gitea/modules/annex"
212,216c213,219
< isTextFile bool
< isLFSFile bool
< fileSize int64
< lfsMeta *lfs.Pointer
< st typesniffer.SniffedType
---
> isTextFile bool
> isLFSFile bool
> isAnnexFile bool
> isAnnexFilePresent bool
> fileSize int64
> lfsMeta *lfs.Pointer
> st typesniffer.SniffedType
219a223,265
> isAnnexed, err := annex.IsAnnexed(blob)
> if err != nil {
> return nil, nil, nil, err
> }
> if isAnnexed {
> // TODO: this code could be merged with the LFS case, especially the redundant type sniffer,
> // but it is *currently* written this way to make merging with the non-annex upstream easier:
> // this way, the git-annex patch is (mostly) pure additions.
>
> annexContent, err := annex.Content(blob)
> if err != nil {
> // If annex.Content returns an error it can mean that the blob does not
> // refer to an annexed file or that it is not present here. Since we already
> // checked that it is annexed the latter must be the case. So we return the
> // content of the blob instead and indicate that the file is indeed annexed,
> // but not present here. The template can then communicate the situation.
> dataRc, err := blob.DataAsync()
> if err != nil {
> return nil, nil, nil, err
> }
>
> buf := make([]byte, 1024)
> n, _ := util.ReadAtMost(dataRc, buf)
> buf = buf[:n]
>
> st := typesniffer.DetectContentType(buf)
> return buf, dataRc, &fileInfo{st.IsText(), false, true, false, blob.Size(), nil, st}, nil
> }
>
> stat, err := annexContent.Stat()
> if err != nil {
> return nil, nil, nil, err
> }
>
> buf := make([]byte, 1024)
> n, _ := util.ReadAtMost(annexContent, buf)
> buf = buf[:n]
>
> st := typesniffer.DetectContentType(buf)
>
> return buf, annexContent, &fileInfo{st.IsText(), false, true, true, stat.Size(), nil, st}, nil
> }
>
234c280
< return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
---
> return buf, dataRc, &fileInfo{isTextFile, false, false, false, blob.Size(), nil, st}, nil
239c285
< return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
---
> return buf, dataRc, &fileInfo{isTextFile, false, false, false, blob.Size(), nil, st}, nil
245c291
< return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
---
> return buf, dataRc, &fileInfo{isTextFile, false, false, false, blob.Size(), nil, st}, nil
265c311
< return buf, dataRc, &fileInfo{st.IsText(), true, meta.Size, &meta.Pointer, st}, nil
---
> return buf, dataRc, &fileInfo{st.IsText(), true, false, false, meta.Size, &meta.Pointer, st}, nil
327a374
> Blob: target.Blob(),
450c497
< if fInfo.isLFSFile {
---
> if fInfo.isLFSFile || fInfo.isAnnexFile {
453a501,507
> if fInfo.isAnnexFile {
> // pre-git-annex v7, all annexed files were represented in-repo as symlinks;
> // but we pretend they aren't, since that's a distracting quirk of git-annex
> // and not a meaningful choice on the user's part
> ctx.Data["FileIsSymlink"] = false
> }
>
460a515,516
> ctx.Data["IsAnnexFile"] = fInfo.isAnnexFile
> ctx.Data["IsAnnexFilePresent"] = fInfo.isAnnexFilePresent
494a551,552
> } else if fInfo.isAnnexFile {
> ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.cannot_edit_annex_files")
548a607
> Blob: entry.Blob(),
602c661
< if !fInfo.isLFSFile {
---
> if !fInfo.isLFSFile && !fInfo.isAnnexFile {
646a706
> Blob: entry.Blob(),