| 1 | package transportscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 5 | |
| 6 | "github.com/go-git/go-billy/v6scip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/" |
| 7 | |
| 8 | "github.com/go-git/go-git/v6/internal/repositoryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/internal/repository`/" |
| 9 | "github.com/go-git/go-git/v6/plumbing/storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/" |
| 10 | "github.com/go-git/go-git/v6/storagescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage`/" |
| 11 | ) |
| 12 | |
| 13 | // UpdateServerInfo updates the server info files in the repository. |
| 14 | // |
| 15 | // It generates a list of available refs for the repository. |
| 16 | // Used by git http transport (dumb), for more information refer to: |
| 17 | // https://git-scm.com/book/id/v2/Git-Internals-Transfer-Protocols#_the_dumb_protocol |
| 18 | func UpdateServerInfoscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/UpdateServerInfo().(s storagescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage`/.Storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage`/Storer#, fs billyscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Filesystem#) error { |
| 19 | pos, ok := s.(storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/.PackedObjectStorerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/PackedObjectStorer#) |
| 20 | if !ok { |
| 21 | return ErrPackedObjectsNotSupportedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/transport`/ErrPackedObjectsNotSupported. |
| 22 | } |
| 23 | |
| 24 | infoRefs, err := fs.Createscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Basic#Create().("info/refs") |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | |
| 29 | defer func() { _ = infoRefs.Closescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#Close().() }() |
| 30 | |
| 31 | refsIter, err := s.IterReferencesscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReferenceStorer#IterReferences.() |
| 32 | if err != nil { |
| 33 | return err |
| 34 | } |
| 35 | |
| 36 | defer refsIter.Closescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReferenceIter#Close.() |
| 37 | |
| 38 | if err := repositoryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/internal/repository`/.WriteInfoRefsscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/internal/repository`/WriteInfoRefs().(infoRefs, s); err != nil { |
| 39 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("failed to write info/refs: %w", err) |
| 40 | } |
| 41 | |
| 42 | infoPacks, err := fs.Createscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Basic#Create().("objects/info/packs") |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | defer func() { _ = infoPacks.Closescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/File#Close().() }() |
| 48 | |
| 49 | if err := repositoryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/internal/repository`/.WriteObjectsInfoPacksscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/internal/repository`/WriteObjectsInfoPacks().(infoPacks, pos); err != nil { |
| 50 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("failed to write objects/info/packs: %w", err) |
| 51 | } |
| 52 | |
| 53 | return nil |
| 54 | } |