StatsContext returns the stats of a commit. Error will be return if context expires. Provided context must be non-nil.
(ctx context.Context)
| 451 | // StatsContext returns the stats of a commit. Error will be return if context |
| 452 | // expires. Provided context must be non-nil. |
| 453 | func (c *Commit) StatsContext(ctx context.Context) (FileStats, error) { |
| 454 | fromTree, err := c.Tree() |
| 455 | if err != nil { |
| 456 | return nil, err |
| 457 | } |
| 458 | |
| 459 | toTree := &Tree{} |
| 460 | if c.NumParents() != 0 { |
| 461 | firstParent, err := c.Parents().Next() |
| 462 | if err != nil { |
| 463 | return nil, err |
| 464 | } |
| 465 | |
| 466 | toTree, err = firstParent.Tree() |
| 467 | if err != nil { |
| 468 | return nil, err |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | patch, err := toTree.PatchContext(ctx, fromTree) |
| 473 | if err != nil { |
| 474 | return nil, err |
| 475 | } |
| 476 | |
| 477 | return getFileStatsFromFilePatches(patch.FilePatches()), nil |
| 478 | } |
| 479 | |
| 480 | func (c *Commit) String() string { |
| 481 | return fmt.Sprintf( |