MCPcopy
hub / github.com/cli/cli / isSameRef

Function isSameRef

pkg/cmd/pr/create/create.go:173–178  ·  view source on GitHub ↗

isSameRef checks if the head and base refs point to the same ref in the same repository. For cross-repository PRs (e.g., from a fork), the qualified head ref will contain an owner prefix (owner:branch), so even if branch names match, they refer to different repos.

(refs creationRefs)

Source from the content-addressed store, hash-verified

171// For cross-repository PRs (e.g., from a fork), the qualified head ref will contain
172// an owner prefix (owner:branch), so even if branch names match, they refer to different repos.
173func isSameRef(refs creationRefs) bool {
174 if strings.Contains(refs.QualifiedHeadRef(), ":") {
175 return false
176 }
177 return refs.UnqualifiedHeadRef() == refs.BaseRef()
178}
179
180// CreateContext stores contextual data about the creation process and is for building up enough
181// data to create a pull request.

Callers 2

Test_isSameRefFunction · 0.85
createRunFunction · 0.85

Calls 4

ContainsMethod · 0.80
QualifiedHeadRefMethod · 0.65
UnqualifiedHeadRefMethod · 0.65
BaseRefMethod · 0.65

Tested by 1

Test_isSameRefFunction · 0.68