VerifyCommit verifies that the supplied hash points to a known commit.
(hash string)
| 186 | |
| 187 | // VerifyCommit verifies that the supplied hash points to a known commit. |
| 188 | func (repo *GitRepo) VerifyCommit(hash string) error { |
| 189 | out, err := repo.runGitCommand("cat-file", "-t", hash) |
| 190 | if err != nil { |
| 191 | return err |
| 192 | } |
| 193 | objectType := strings.TrimSpace(string(out)) |
| 194 | if objectType != "commit" { |
| 195 | return fmt.Errorf("Hash %q points to a non-commit object of type %q", hash, objectType) |
| 196 | } |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | // VerifyGitRef verifies that the supplied ref points to a known commit. |
| 201 | func (repo *GitRepo) VerifyGitRef(ref string) error { |
nothing calls this directly
no test coverage detected