ResolveInput freezes this run's commit endpoints by asking git, following the input-mode matrix: - range: base = merge-base(from,to); head = the commit `to` resolves to; exact_range = base..head only when both resolve. - commit: head = the commit resolved from `commit`; base is the first par
(ctx context.Context)
| 122 | // It runs read-only git queries and never returns an error: an unresolvable |
| 123 | // endpoint is reported as an empty field, never a fabricated SHA. |
| 124 | func (p *Provider) ResolveInput(ctx context.Context) InputResolution { |
| 125 | switch p.mode { |
| 126 | case ModeRange: |
| 127 | base := p.MergeBase(ctx) |
| 128 | head := p.resolveCommit(ctx, p.to) |
| 129 | r := InputResolution{ResolvedBase: base, ResolvedHead: head} |
| 130 | if base != "" && head != "" { |
| 131 | r.ExactRange = base + ".." + head |
| 132 | } |
| 133 | return r |
| 134 | case ModeCommit: |
| 135 | head := p.resolveCommit(ctx, p.commit) |
| 136 | r := InputResolution{ResolvedHead: head} |
| 137 | if parents := p.commitParents(ctx, p.commit); len(parents) > 0 && head != "" { |
| 138 | // GetDiff renders merge commits against their first parent, so the |
| 139 | // manifest must record that same concrete comparison base. |
| 140 | r.ResolvedBase = parents[0] |
| 141 | r.ExactRange = parents[0] + ".." + head |
| 142 | } |
| 143 | return r |
| 144 | case ModeWorkspace: |
| 145 | // base = current HEAD if the repository has one; an unborn repository has |
| 146 | // no HEAD, so this stays empty rather than fabricating a base. |
| 147 | return InputResolution{ResolvedBase: p.resolveCommit(ctx, "HEAD")} |
| 148 | default: |
| 149 | return InputResolution{} |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // IsRangeMode returns true when comparing two refs. |
| 154 | func (p *Provider) IsRangeMode() bool { |