MCPcopy Create free account
hub / github.com/alibaba/open-code-review / ResolveInput

Method ResolveInput

internal/diff/git.go:158–185  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

156// It runs read-only git queries and never returns an error: an unresolvable
157// endpoint is reported as an empty field, never a fabricated SHA.
158func (p *Provider) ResolveInput(ctx context.Context) InputResolution {
159 switch p.mode {
160 case ModeRange:
161 base := p.MergeBase(ctx)
162 head := p.resolveCommit(ctx, p.to)
163 r := InputResolution{ResolvedBase: base, ResolvedHead: head}
164 if base != "" && head != "" {
165 r.ExactRange = base + ".." + head
166 }
167 return r
168 case ModeCommit:
169 head := p.resolveCommit(ctx, p.commit)
170 r := InputResolution{ResolvedHead: head}
171 if parents := p.commitParents(ctx, p.commit); len(parents) > 0 && head != "" {
172 // GetDiff renders merge commits against their first parent, so the
173 // manifest must record that same concrete comparison base.
174 r.ResolvedBase = parents[0]
175 r.ExactRange = parents[0] + ".." + head
176 }
177 return r
178 case ModeWorkspace:
179 // base = current HEAD if the repository has one; an unborn repository has
180 // no HEAD, so this stays empty rather than fabricating a base.
181 return InputResolution{ResolvedBase: p.resolveCommit(ctx, "HEAD")}
182 default:
183 return InputResolution{}
184 }
185}
186
187// IsRangeMode returns true when comparing two refs.
188func (p *Provider) IsRangeMode() bool {

Callers 9

TestResolveInput_RangeFunction · 0.95
resolveInputBeforeDiffFunction · 0.80
resolveCommitHeadFunction · 0.80
loadDiffsMethod · 0.80

Calls 3

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95