(patchFile string)
| 164 | } |
| 165 | |
| 166 | func parse(patchFile string) ([]Patch, error) { |
| 167 | var r io.ReadCloser |
| 168 | if patchFile == "-" { |
| 169 | r = os.Stdin |
| 170 | } else { |
| 171 | f, err := os.Open(patchFile) |
| 172 | if err != nil { |
| 173 | return nil, fmt.Errorf("open patch file failed: %w", err) |
| 174 | } |
| 175 | r = f |
| 176 | } |
| 177 | defer closeQuitely(r) |
| 178 | |
| 179 | mbr := mboxMessageReader{r: r} |
| 180 | |
| 181 | var patches []Patch |
| 182 | for mbr.Next() { |
| 183 | files, preamble, err := gitdiff.Parse(&mbr) |
| 184 | if err != nil { |
| 185 | return nil, fmt.Errorf("parsing patch failed: %w", err) |
| 186 | } |
| 187 | |
| 188 | var header *gitdiff.PatchHeader |
| 189 | if len(preamble) > 0 { |
| 190 | header, err = gitdiff.ParsePatchHeader(preamble) |
| 191 | if err != nil { |
| 192 | fmt.Fprintf(os.Stderr, "warning: invalid patch header: %v", err) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | patches = append(patches, Patch{patchFile, files, header}) |
| 197 | } |
| 198 | return patches, nil |
| 199 | } |
| 200 | |
| 201 | func execute(ctx context.Context, client *github.Client, patchFiles []string, opts *Options) (*Result, error) { |
| 202 | targetRepo := *opts.Repository |
no test coverage detected