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

Method ResolveInput

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

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

Calls 4

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95