MCPcopy
hub / github.com/go-git/go-git / StatsContext

Method StatsContext

plumbing/object/commit.go:453–478  ·  view source on GitHub ↗

StatsContext returns the stats of a commit. Error will be return if context expires. Provided context must be non-nil.

(ctx context.Context)

Source from the content-addressed store, hash-verified

451// StatsContext returns the stats of a commit. Error will be return if context
452// expires. Provided context must be non-nil.
453func (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
480func (c *Commit) String() string {
481 return fmt.Sprintf(

Callers 2

StatsMethod · 0.95
TestStatsMethod · 0.80

Calls 8

TreeMethod · 0.95
NumParentsMethod · 0.95
ParentsMethod · 0.95
PatchContextMethod · 0.95
NextMethod · 0.65
TreeMethod · 0.65
FilePatchesMethod · 0.65

Tested by 1

TestStatsMethod · 0.64