(opts *CreateOptions, remoteURL, branch string)
| 707 | } |
| 708 | |
| 709 | func cloneWithRetry(opts *CreateOptions, remoteURL, branch string) error { |
| 710 | // Allow injecting alternative BackOff in tests. |
| 711 | if opts.BackOff == nil { |
| 712 | opts.BackOff = backoff.NewConstantBackOff(3 * time.Second) |
| 713 | } |
| 714 | |
| 715 | var args []string |
| 716 | if branch != "" { |
| 717 | args = append(args, "--branch", branch) |
| 718 | } |
| 719 | |
| 720 | ctx := context.Background() |
| 721 | return backoff.Retry(func() error { |
| 722 | stderr := &bytes.Buffer{} |
| 723 | _, err := opts.GitClient.Clone(ctx, remoteURL, args, git.WithStderr(stderr)) |
| 724 | |
| 725 | var execError errWithExitCode |
| 726 | if errors.As(err, &execError) && execError.ExitCode() == 128 { |
| 727 | return err |
| 728 | } else { |
| 729 | _, _ = io.Copy(opts.IO.ErrOut, stderr) |
| 730 | } |
| 731 | |
| 732 | return backoff.Permanent(err) |
| 733 | }, backoff.WithContext(backoff.WithMaxRetries(opts.BackOff, 3), ctx)) |
| 734 | } |
| 735 | |
| 736 | func sourceInit(gitClient *git.Client, io *iostreams.IOStreams, remoteURL, baseRemote string) error { |
| 737 | cs := io.ColorScheme() |
no test coverage detected