MCPcopy Index your code
hub / github.com/google/git-appraise / HasObject

Method HasObject

repository/git.go:129–140  ·  view source on GitHub ↗

HasObject returns whether or not the repo contains an object with the given hash.

(hash string)

Source from the content-addressed store, hash-verified

127
128// HasObject returns whether or not the repo contains an object with the given hash.
129func (repo *GitRepo) HasObject(hash string) (bool, error) {
130 _, err := repo.runGitCommand("cat-file", "-e", hash)
131 if err == nil {
132 // We verified the object exists
133 return true, nil
134 }
135 if _, ok := err.(*exec.ExitError); ok {
136 return false, nil
137 }
138 // Got an unexpected error
139 return false, err
140}
141
142// GetPath returns the path to the repo.
143func (repo *GitRepo) GetPath() string {

Callers

nothing calls this directly

Calls 1

runGitCommandMethod · 0.95

Tested by

no test coverage detected