( ctx context.Context, repoPath string, sha sha.SHA, )
| 236 | } |
| 237 | |
| 238 | func getCommitFileStats( |
| 239 | ctx context.Context, |
| 240 | repoPath string, |
| 241 | sha sha.SHA, |
| 242 | ) ([]CommitFileStats, error) { |
| 243 | g, ctx := errgroup.WithContext(ctx) |
| 244 | var changeInfoChanges map[string]changeInfoChange |
| 245 | var changeInfoTypes map[string]changeInfoType |
| 246 | |
| 247 | g.Go(func() error { |
| 248 | var err error |
| 249 | changeInfoChanges, err = getChangeInfoChanges(ctx, repoPath, sha) |
| 250 | return err |
| 251 | }) |
| 252 | |
| 253 | g.Go(func() error { |
| 254 | var err error |
| 255 | changeInfoTypes, err = getChangeInfoTypes(ctx, repoPath, sha) |
| 256 | return err |
| 257 | }) |
| 258 | |
| 259 | if err := g.Wait(); err != nil { |
| 260 | return nil, fmt.Errorf("failed to get change infos: %w", err) |
| 261 | } |
| 262 | |
| 263 | if len(changeInfoTypes) == 0 { |
| 264 | return []CommitFileStats{}, nil |
| 265 | } |
| 266 | |
| 267 | fileStats := make([]CommitFileStats, len(changeInfoChanges)) |
| 268 | i := 0 |
| 269 | for path, info := range changeInfoChanges { |
| 270 | fileStats[i] = CommitFileStats{ |
| 271 | Path: changeInfoTypes[path].Path, |
| 272 | OldPath: changeInfoTypes[path].OldPath, |
| 273 | ChangeType: changeInfoTypes[path].Status, |
| 274 | Insertions: info.Insertions, |
| 275 | Deletions: info.Deletions, |
| 276 | } |
| 277 | i++ |
| 278 | } |
| 279 | return fileStats, nil |
| 280 | } |
| 281 | |
| 282 | // In case of rename of a file, same commit will be listed twice - Once in old file and second time in new file. |
| 283 | // Hence, we are making it a pattern to only list it as part of new file and not as part of old file. |
no test coverage detected
searching dependent graphs…