MCPcopy Create free account
hub / github.com/cli/cli / syncBranchCmds

Function syncBranchCmds

pkg/cmd/pr/checkout/checkout.go:416–426  ·  view source on GitHub ↗

syncBranchCmds syncs a branch to ref: a hard reset when force is set, otherwise a fast-forward-only merge. A non-empty path runs the commands there.

(path, ref string, force bool)

Source from the content-addressed store, hash-verified

414// syncBranchCmds syncs a branch to ref: a hard reset when force is set,
415// otherwise a fast-forward-only merge. A non-empty path runs the commands there.
416func syncBranchCmds(path, ref string, force bool) [][]string {
417 var prefix []string
418 if path != "" {
419 prefix = []string{"-C", path}
420 }
421 if force {
422 return [][]string{append(prefix, "reset", "--hard", ref)}
423 }
424 // TODO: check if non-fast-forward and suggest to use `--force`
425 return [][]string{append(prefix, "merge", "--ff-only", ref)}
426}
427
428func worktreeCheckoutCmds(path, branch, ref string, force bool) [][]string {
429 cmds := [][]string{{"-C", path, "checkout", branch}}

Callers 3

cmdsForExistingRemoteFunction · 0.85
cmdsForMissingRemoteFunction · 0.85
worktreeCheckoutCmdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected