|
5 | 5 | "errors"
|
6 | 6 | "fmt"
|
7 | 7 | "os"
|
| 8 | + "os/exec" |
8 | 9 | "os/user"
|
9 | 10 | "strings"
|
10 | 11 | "time"
|
@@ -60,8 +61,24 @@ var restoreXcodeDerivedDataFilesCmd = &cobra.Command{
|
60 | 61 | return fmt.Errorf("read auth config from environments: %w", err)
|
61 | 62 | }
|
62 | 63 |
|
63 |
| - op, cmdError := restoreXcodeDerivedDataFilesCmdFn(cmd.Context(), authConfig, XCodeCacheMetadataPath, projectRoot, |
64 |
| - cacheKey, logger, tracker, startT, os.Getenv, isDebugLogMode, skipExisting, forceOverwrite, maxLoggedErrors) |
| 64 | + op, cmdError := restoreXcodeDerivedDataFilesCmdFn(cmd.Context(), |
| 65 | + authConfig, |
| 66 | + XCodeCacheMetadataPath, |
| 67 | + projectRoot, |
| 68 | + cacheKey, |
| 69 | + logger, |
| 70 | + tracker, |
| 71 | + startT, |
| 72 | + os.Getenv, |
| 73 | + func(name string, v ...string) (string, error) { |
| 74 | + output, err := exec.Command(name, v...).Output() |
| 75 | + |
| 76 | + return string(output), err |
| 77 | + }, |
| 78 | + isDebugLogMode, |
| 79 | + skipExisting, |
| 80 | + forceOverwrite, |
| 81 | + maxLoggedErrors) |
65 | 82 | if op != nil {
|
66 | 83 | if cmdError != nil {
|
67 | 84 | errStr := cmdError.Error()
|
@@ -97,15 +114,24 @@ func init() {
|
97 | 114 | restoreXcodeDerivedDataFilesCmd.Flags().Int("max-logged-errors", 150, "The maximum number of errors logged to the console during restoring the cache.")
|
98 | 115 | }
|
99 | 116 |
|
100 |
| -func restoreXcodeDerivedDataFilesCmdFn(ctx context.Context, authConfig common.CacheAuthConfig, cacheMetadataPath, projectRoot, providedCacheKey string, logger log.Logger, |
101 |
| - tracker xcode.StepAnalyticsTracker, startT time.Time, envProvider func(string) string, isDebugLogMode, skipExisting, forceOverwrite bool, maxLoggedDownloadErrors int) (*xa.CacheOperation, error) { |
| 117 | +func restoreXcodeDerivedDataFilesCmdFn(ctx context.Context, |
| 118 | + authConfig common.CacheAuthConfig, |
| 119 | + cacheMetadataPath, projectRoot, providedCacheKey string, |
| 120 | + logger log.Logger, |
| 121 | + tracker xcode.StepAnalyticsTracker, |
| 122 | + startT time.Time, |
| 123 | + envProvider func(string) string, |
| 124 | + commandFunc func(string, ...string) (string, error), |
| 125 | + isDebugLogMode, skipExisting, forceOverwrite bool, |
| 126 | + maxLoggedDownloadErrors int) (*xa.CacheOperation, error) { |
102 | 127 | op := newCacheOperation(startT, xa.OperationTypeDownload, envProvider)
|
103 | 128 | kvClient, err := createKVClient(ctx,
|
104 | 129 | CreateKVClientParams{
|
105 | 130 | CacheOperationID: op.OperationID,
|
106 | 131 | ClientName: ClientNameXcode,
|
107 | 132 | AuthConfig: authConfig,
|
108 | 133 | EnvProvider: envProvider,
|
| 134 | + CommandFunc: commandFunc, |
109 | 135 | Logger: logger,
|
110 | 136 | })
|
111 | 137 | if err != nil {
|
|
0 commit comments