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

Method ResolveInput

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

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.
124func (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.
154func (p *Provider) IsRangeMode() bool {

Calls 3

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95