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

Method File

plumbing/object/tree.go:75–90  ·  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

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