MCPcopy
hub / github.com/go-git/go-git / NewRepositoryFromPackfile

Method NewRepositoryFromPackfile

common_test.go:102–128  ·  view source on GitHub ↗
(f *fixtures.Fixture)

Source from the content-addressed store, hash-verified

100}
101
102func (s *BaseSuite) NewRepositoryFromPackfile(f *fixtures.Fixture) *Repository {
103 h := f.PackfileHash
104 if r, ok := s.cache[h]; ok {
105 return r
106 }
107
108 storer := memory.NewStorage()
109 p := f.Packfile()
110 defer func() { _ = p.Close() }()
111
112 if err := packfile.UpdateObjectStorage(storer, p); err != nil {
113 panic(err)
114 }
115
116 err := storer.SetReference(plumbing.NewHashReference(plumbing.HEAD, plumbing.NewHash(f.Head)))
117 if err != nil {
118 panic(err)
119 }
120
121 r, err := Open(storer, memfs.New())
122 if err != nil {
123 panic(err)
124 }
125
126 s.cache[h] = r
127 return r
128}
129
130func (s *BaseSuite) GetBasicLocalRepositoryURL() string {
131 fixture := fixtures.Basic().One()

Callers 1

TestBlameMethod · 0.80

Calls 7

NewStorageFunction · 0.92
UpdateObjectStorageFunction · 0.92
NewHashReferenceFunction · 0.92
NewHashFunction · 0.92
OpenFunction · 0.85
CloseMethod · 0.65
SetReferenceMethod · 0.65

Tested by

no test coverage detected