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)
| 585 | // ^{commit} peel collapses a tag or tree ref to its commit; --verify --quiet |
| 586 | // makes an unresolvable ref exit non-zero silently rather than printing an error. |
| 587 | func (p *Provider) resolveCommit(ctx context.Context, ref string) string { |
| 588 | out, err := p.runGit(ctx, "rev-parse", "--verify", "--quiet", "--end-of-options", ref+"^{commit}") |
| 589 | if err != nil { |
| 590 | return "" |
| 591 | } |
| 592 | return firstLine(out) |
| 593 | } |
| 594 | |
| 595 | // commitParents returns the parent commit SHAs of ref: zero for a root commit, |
| 596 | // one for an ordinary commit, and 2+ for a merge. It uses `rev-list --parents -n |
no test coverage detected