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

Function executeCmds

pkg/cmd/pr/checkout/checkout.go:356–382  ·  view source on GitHub ↗
(client *git.Client, credentialPattern git.CredentialPattern, cmdQueue [][]string)

Source from the content-addressed store, hash-verified

354}
355
356func executeCmds(client *git.Client, credentialPattern git.CredentialPattern, cmdQueue [][]string) error {
357 for _, args := range cmdQueue {
358 // Determine the git sub-command, skipping any -C <path> prefix.
359 subCmd := args[0]
360 if len(args) >= 3 && args[0] == "-C" {
361 subCmd = args[2]
362 }
363
364 var err error
365 var cmd *git.Command
366 switch subCmd {
367 case "submodule":
368 cmd, err = authenticatedCommand(client, credentialPattern, args)
369 case "fetch":
370 cmd, err = authenticatedCommand(client, git.AllMatchingCredentialsPattern, args)
371 default:
372 cmd, err = client.Command(context.Background(), args...)
373 }
374 if err != nil {
375 return err
376 }
377 if err := cmd.Run(); err != nil {
378 return err
379 }
380 }
381 return nil
382}
383
384// authenticatedCommand builds an authenticated git command, transparently
385// handling a leading -C <path> prefix. AuthenticatedCommand prepends

Callers 1

checkoutRunFunction · 0.85

Calls 3

RunMethod · 0.95
authenticatedCommandFunction · 0.85
CommandMethod · 0.80

Tested by

no test coverage detected