resolveCommit returns the immutable commit SHA a ref points at, or "" when the ref does not resolve to a commit (e.g. an unborn HEAD, or a bad ref). The ^{commit} peel collapses a tag or tree ref to its commit; --verify --quiet makes an unresolvable ref exit non-zero silently rather than printing an
(ctx context.Context, ref string)
| 492 | // ^{commit} peel collapses a tag or tree ref to its commit; --verify --quiet |
| 493 | // makes an unresolvable ref exit non-zero silently rather than printing an error. |
| 494 | func (p *Provider) resolveCommit(ctx context.Context, ref string) string { |
| 495 | out, err := p.runGit(ctx, "rev-parse", "--verify", "--quiet", "--end-of-options", ref+"^{commit}") |
| 496 | if err != nil { |
| 497 | return "" |
| 498 | } |
| 499 | return firstLine(out) |
| 500 | } |
| 501 | |
| 502 | // commitParents returns the parent commit SHAs of ref: zero for a root commit, |
| 503 | // one for an ordinary commit, and 2+ for a merge. It uses `rev-list --parents -n |
no test coverage detected