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

Method ResolveInput

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

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

Calls 3

MergeBaseMethod · 0.95
resolveCommitMethod · 0.95
commitParentsMethod · 0.95