(opts *UploadOptions)
| 75 | } |
| 76 | |
| 77 | func uploadRun(opts *UploadOptions) error { |
| 78 | httpClient, err := opts.HttpClient() |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | baseRepo, err := opts.BaseRepo() |
| 84 | if err != nil { |
| 85 | return err |
| 86 | } |
| 87 | |
| 88 | release, err := shared.FetchRelease(context.Background(), httpClient, baseRepo, opts.TagName) |
| 89 | if err != nil { |
| 90 | return err |
| 91 | } |
| 92 | |
| 93 | uploadURL := release.UploadURL |
| 94 | if idx := strings.IndexRune(uploadURL, '{'); idx > 0 { |
| 95 | uploadURL = uploadURL[:idx] |
| 96 | } |
| 97 | |
| 98 | var existingNames []string |
| 99 | for _, a := range opts.Assets { |
| 100 | sanitizedFileName := sanitizeFileName(a.Name) |
| 101 | for _, ea := range release.Assets { |
| 102 | if ea.Name == sanitizedFileName { |
| 103 | a.ExistingURL = ea.APIURL |
| 104 | existingNames = append(existingNames, ea.Name) |
| 105 | break |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | if len(existingNames) > 0 && !opts.OverwriteExisting { |
| 111 | return fmt.Errorf("asset under the same name already exists: %v", existingNames) |
| 112 | } |
| 113 | |
| 114 | opts.IO.StartProgressIndicator() |
| 115 | err = shared.ConcurrentUpload(httpClient, uploadURL, opts.Concurrency, opts.Assets) |
| 116 | opts.IO.StopProgressIndicator() |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | |
| 121 | if opts.IO.IsStdoutTTY() { |
| 122 | iofmt := opts.IO.ColorScheme() |
| 123 | fmt.Fprintf(opts.IO.Out, "Successfully uploaded %s to %s\n", |
| 124 | text.Pluralize(len(opts.Assets), "asset"), |
| 125 | iofmt.Bold(release.TagName)) |
| 126 | } |
| 127 | |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | // this method attempts to mimic the same functionality on the client that the platform does on |
| 132 | // uploaded assets in order to allow the --clobber logic work correctly, since that feature is |
no test coverage detected