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

Method File

plumbing/object/tree.go:77–92  ·  view source on GitHub ↗

File returns the hash of the file identified by the `path` argument. The path is interpreted as relative to the tree receiver.

(path string)

Source from the content-addressed store, hash-verified

75// File returns the hash of the file identified by the `path` argument.
76// The path is interpreted as relative to the tree receiver.
77func (t *Tree) File(path string) (*File, error) {
78 e, err := t.FindEntry(path)
79 if err != nil {
80 return nil, ErrFileNotFound
81 }
82
83 blob, err := GetBlob(t.s, e.Hash)
84 if err != nil {
85 if err == plumbing.ErrObjectNotFound {
86 return nil, ErrFileNotFound
87 }
88 return nil, err
89 }
90
91 return NewFile(path, e.Mode, blob), nil
92}
93
94// Size returns the plaintext size of an object, without reading it
95// into memory.

Callers 8

TestScoreFilesMethod · 0.45
TestContentsMethod · 0.45
TestLinesMethod · 0.45
TestFileMethod · 0.45
TestFileMethod · 0.45
TestFileNotFoundMethod · 0.45

Calls 3

FindEntryMethod · 0.95
GetBlobFunction · 0.85
NewFileFunction · 0.85

Tested by 8

TestScoreFilesMethod · 0.36
TestContentsMethod · 0.36
TestLinesMethod · 0.36
TestFileMethod · 0.36
TestFileMethod · 0.36
TestFileNotFoundMethod · 0.36