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

Function syncBranchCmds

pkg/cmd/pr/checkout/checkout.go:344–354  ·  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

342// syncBranchCmds syncs a branch to ref: a hard reset when force is set,
343// otherwise a fast-forward-only merge. A non-empty path runs the commands there.
344func syncBranchCmds(path, ref string, force bool) [][]string {
345 var prefix []string
346 if path != "" {
347 prefix = []string{"-C", path}
348 }
349 if force {
350 return [][]string{append(prefix, "reset", "--hard", ref)}
351 }
352 // TODO: check if non-fast-forward and suggest to use `--force`
353 return [][]string{append(prefix, "merge", "--ff-only", ref)}
354}
355
356func executeCmds(client *git.Client, credentialPattern git.CredentialPattern, cmdQueue [][]string) error {
357 for _, args := range cmdQueue {

Callers 2

cmdsForExistingRemoteFunction · 0.85
cmdsForMissingRemoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected