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

Method CreateFile

internal/git/operations.go:44–58  ·  view source on GitHub ↗

CreateFile is a convenience method to set the contents of a file in the repo and stage it.

(filename string, data []byte)

Source from the content-addressed store, hash-verified

42// CreateFile is a convenience method to set the contents of a file in the
43// repo and stage it.
44func (r *Repository) CreateFile(filename string, data []byte) error {
45 f, err := r.WorktreeFS.Create(filename)
46 if err != nil {
47 return err
48 }
49
50 _, err = f.Write(data)
51 if err != nil {
52 return err
53 }
54
55 _, err = r.Worktree.Add(filename)
56
57 return err
58}
59
60// UpdateFile is a convenience method to get the contents of a file, pass it
61// to a callback, write the contents back to the file if no error was

Callers 1

UpdateFileMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected