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

Method ResolveInput

internal/diff/git.go:162–188  ·  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

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

Calls 4

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95