StatsContext returns the stats of a commit. Error will be return if context expires. Provided context must be non-nil.
(ctx context.Context)
| 372 | // StatsContext returns the stats of a commit. Error will be return if context |
| 373 | // expires. Provided context must be non-nil. |
| 374 | func (c *Commit) StatsContext(ctx context.Context) (FileStats, error) { |
| 375 | fromTree, err := c.Tree() |
| 376 | if err != nil { |
| 377 | return nil, err |
| 378 | } |
| 379 | |
| 380 | toTree := &Tree{} |
| 381 | if c.NumParents() != 0 { |
| 382 | firstParent, err := c.Parents().Next() |
| 383 | if err != nil { |
| 384 | return nil, err |
| 385 | } |
| 386 | |
| 387 | toTree, err = firstParent.Tree() |
| 388 | if err != nil { |
| 389 | return nil, err |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | patch, err := toTree.PatchContext(ctx, fromTree) |
| 394 | if err != nil { |
| 395 | return nil, err |
| 396 | } |
| 397 | |
| 398 | return getFileStatsFromFilePatches(patch.FilePatches()), nil |
| 399 | } |
| 400 | |
| 401 | func (c *Commit) String() string { |
| 402 | return fmt.Sprintf( |