MCPcopy Create free account
hub / github.com/go-git/go-git / objectPacks

Method objectPacks

storage/filesystem/dotgit/dotgit.go:234–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

232}
233
234func (d *DotGit) objectPacks() ([]plumbing.Hash, error) {
235 packDir := d.fs.Join(objectsPath, packPath)
236 files, err := d.fs.ReadDir(packDir)
237 if err != nil {
238 if os.IsNotExist(err) {
239 return nil, nil
240 }
241
242 return nil, err
243 }
244
245 var packs []plumbing.Hash
246 for _, f := range files {
247 n := f.Name()
248 if !strings.HasSuffix(n, packExt) || !strings.HasPrefix(n, packPrefix) {
249 continue
250 }
251
252 h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
253 if h.IsZero() {
254 // Ignore files with badly-formatted names.
255 continue
256 }
257 packs = append(packs, h)
258 }
259
260 return packs, nil
261}
262
263func (d *DotGit) objectPackPath(hash plumbing.Hash, extension string) string {
264 return d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.%s", hash.String(), extension))

Callers 2

ObjectPacksMethod · 0.95
genPackListMethod · 0.95

Calls 5

IsZeroMethod · 0.95
NewHashFunction · 0.92
JoinMethod · 0.80
NameMethod · 0.65
ReadDirMethod · 0.45

Tested by

no test coverage detected