MCPcopy Create free account
hub / github.com/antonmedv/gitmal / BlobContent

Function BlobContent

pkg/git/git.go:198–216  ·  view source on GitHub ↗
(ref Ref, path string, repoDir string)

Source from the content-addressed store, hash-verified

196}
197
198func BlobContent(ref Ref, path string, repoDir string) ([]byte, bool, error) {
199 if ref.IsEmpty() {
200 ref = NewRef("HEAD")
201 }
202 // Use `git show ref:path` to get the blob content at that ref
203 cmd := exec.Command("git", "show", ref.String()+":"+path)
204 if repoDir != "" {
205 cmd.Dir = repoDir
206 }
207 out, err := cmd.Output()
208 if err != nil {
209 // include stderr if available
210 if ee, ok := err.(*exec.ExitError); ok {
211 return nil, false, fmt.Errorf("git show failed: %v: %s", err, string(ee.Stderr))
212 }
213 return nil, false, fmt.Errorf("git show failed: %w", err)
214 }
215 return out, IsBinary(out), nil
216}
217
218func Commits(ref Ref, repoDir string) ([]Commit, error) {
219 format := []string{

Callers 2

readmeFunction · 0.92
generateBlobsFunction · 0.92

Calls 5

NewRefFunction · 0.85
IsBinaryFunction · 0.85
IsEmptyMethod · 0.80
ErrorfMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected