Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

at icy/sntnrt 912 B View raw
1package gitea 2 3import ( 4 "context" 5 "errors" 6 "io" 7 8 "github.com/go-git/go-git/v5/config" 9) 10 11var ( 12 ErrMissingGitModules = errors.New("no .gitmodules file found") 13 ErrInvalidGitModules = errors.New("invalid .gitmodules file") 14) 15 16func GetSubmodules(ctx context.Context, repoPath, ref string) (*config.Modules, error) { 17 modulesEntry, err := GetEntry(ctx, repoPath, ref, ".gitmodules") 18 if err != nil { 19 return nil, ErrMissingGitModules 20 } 21 22 // at the moment we do not strictly limit the size of the .gitmodules file because some users would have huge .gitmodules files (>1MB) 23 _, reader, err := ReadBlob(ctx, repoPath, modulesEntry.Hash) 24 if err != nil { 25 return nil, err 26 } 27 28 modulesContent, err := io.ReadAll(reader) 29 if err != nil { 30 return nil, err 31 } 32 33 modules := config.NewModules() 34 if err := modules.Unmarshal(modulesContent); err != nil { 35 return nil, ErrInvalidGitModules 36 } 37 38 return modules, nil 39}