MCPcopy Create free account
hub / github.com/belak/gitdir / writeIfDifferent

Function writeIfDifferent

internal/git/repository.go:166–181  ·  view source on GitHub ↗
(fs billy.Basic, path string, data []byte)

Source from the content-addressed store, hash-verified

164}
165
166func writeIfDifferent(fs billy.Basic, path string, data []byte) error {
167 var oldData []byte
168
169 f, err := fs.Open(path)
170 if err == nil {
171 defer f.Close()
172 oldData, _ = io.ReadAll(f)
173 }
174
175 // Quick check to avoid unneeded writes
176 if !bytes.Equal(oldData, data) {
177 return util.WriteFile(fs, path, data, os.ModePerm)
178 }
179
180 return nil
181}
182
183// hookTemplate is based on a combination of sources, but allows us to run
184// multiple hooks from a directory (all of them will always be run) and only

Callers 1

ensureHooksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected