MCPcopy Create free account
hub / github.com/go-git/go-git / StatsContext

Method StatsContext

plumbing/object/commit.go:374–399  ·  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

372// StatsContext returns the stats of a commit. Error will be return if context
373// expires. Provided context must be non-nil.
374func (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
401func (c *Commit) String() string {
402 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