mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 11:11:35 +00:00
Warn when a Git repository is uploaded with Git LFS-tracked files.
This commit is contained in:
18
src/fetch.go
18
src/fetch.go
@@ -9,6 +9,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/c2h5oh/datasize"
|
||||
"github.com/go-git/go-billy/v6/osfs"
|
||||
@@ -209,6 +210,8 @@ func FetchRepository(
|
||||
datasize.ByteSize(dataBytesTransferred).HR(),
|
||||
)
|
||||
|
||||
warnAboutGitLFS(ctx, manifest)
|
||||
|
||||
return manifest, nil
|
||||
}
|
||||
|
||||
@@ -254,3 +257,18 @@ func readGitBlob(
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func warnAboutGitLFS(ctx context.Context, manifest *Manifest) {
|
||||
gitattributes := ReadGitAttributes(ctx, manifest)
|
||||
for _, name := range slices.Sorted(maps.Keys(manifest.GetContents())) {
|
||||
entry := manifest.GetContents()[name]
|
||||
if !IsEntryRegularFile(entry) {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(name, "/")
|
||||
attrs, _ := gitattributes.Match(parts, nil)
|
||||
if attr, ok := attrs["filter"]; ok && attr.Value() == "lfs" {
|
||||
AddProblem(manifest, name, "git-pages does not support Git LFS; move this file into Git or use incremental uploads")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user