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

Method ResolveInput

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

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

Calls 3

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95