MCPcopy Index your code
hub / github.com/belak/gitdir / UpdateFile

Method UpdateFile

internal/git/operations.go:63–72  ·  view source on GitHub ↗

UpdateFile is a convenience method to get the contents of a file, pass it to a callback, write the contents back to the file if no error was returned, and stage the file.

(filename string, cb func([]byte) ([]byte, error))

Source from the content-addressed store, hash-verified

61// to a callback, write the contents back to the file if no error was
62// returned, and stage the file.
63func (r *Repository) UpdateFile(filename string, cb func([]byte) ([]byte, error)) error {
64 data, _ := r.GetFile(filename)
65
66 data, err := cb(data)
67 if err != nil {
68 return err
69 }
70
71 return r.CreateFile(filename, data)
72}
73
74// Commit is a convenience method to make working with the worktree a little
75// bit easier.

Callers 4

ensureAdminConfigYamlMethod · 0.80
ensureAdminUserMethod · 0.80
ensureAdminEd25519KeyMethod · 0.80
ensureAdminRSAKeyMethod · 0.80

Calls 2

GetFileMethod · 0.95
CreateFileMethod · 0.95

Tested by

no test coverage detected