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

Method Initialize

storage/filesystem/dotgit/dotgit.go:126–150  ·  view source on GitHub ↗

Initialize creates all the folder scaffolding.

()

Source from the content-addressed store, hash-verified

124
125// Initialize creates all the folder scaffolding.
126func (d *DotGit) Initialize() error {
127 mustExists := []string{
128 d.fs.Join("objects", "info"),
129 d.fs.Join("objects", "pack"),
130 d.fs.Join("refs", "heads"),
131 d.fs.Join("refs", "tags"),
132 }
133
134 for _, path := range mustExists {
135 _, err := d.fs.Stat(path)
136 if err == nil {
137 continue
138 }
139
140 if !os.IsNotExist(err) {
141 return err
142 }
143
144 if err := d.fs.MkdirAll(path, os.ModeDir|os.ModePerm); err != nil {
145 return err
146 }
147 }
148
149 return nil
150}
151
152// Close closes all opened files.
153func (d *DotGit) Close() error {

Callers 4

InitMethod · 0.80
TestInitializeMethod · 0.80
testAlternatesFunction · 0.80
TestAlternatesDupesFunction · 0.80

Calls 3

JoinMethod · 0.80
StatMethod · 0.80
MkdirAllMethod · 0.80

Tested by 3

TestInitializeMethod · 0.64
testAlternatesFunction · 0.64
TestAlternatesDupesFunction · 0.64