MCPcopy Index your code
hub / github.com/github/git-sizer / RegisterCommit

Method RegisterCommit

sizes/graph.go:653–685  ·  view source on GitHub ↗

Record that the specified `oid` is the specified `commit`.

(oid git.OID, commit *git.Commit)

Source from the content-addressed store, hash-verified

651
652// Record that the specified `oid` is the specified `commit`.
653func (g *Graph) RegisterCommit(oid git.OID, commit *git.Commit) {
654 g.commitLock.Lock()
655 if _, ok := g.commitSizes[oid]; ok {
656 panic(fmt.Sprintf("commit %s registered twice!", oid))
657 }
658 g.commitLock.Unlock()
659
660 // The number of direct parents of this commit.
661 parentCount := counts.NewCount32(uint64(len(commit.Parents)))
662
663 // The size of the items we know so far:
664 size := CommitSize{}
665
666 // The tree:
667 treeSize := g.GetTreeSize(commit.Tree)
668 size.addTree(treeSize)
669
670 for _, parent := range commit.Parents {
671 parentSize := g.GetCommitSize(parent)
672 size.addParent(parentSize)
673 }
674
675 // Add 1 for this commit itself:
676 size.MaxAncestorDepth.Increment(1)
677
678 g.commitLock.Lock()
679 g.commitSizes[oid] = size
680 g.commitLock.Unlock()
681
682 g.historyLock.Lock()
683 g.historySize.recordCommit(g, oid, size, commit.Size, parentCount)
684 g.historyLock.Unlock()
685}
686
687func (g *Graph) RequireTagSize(oid git.OID, listener func(TagSize)) (TagSize, bool) {
688 g.tagLock.Lock()

Callers 1

ScanRepositoryUsingGraphFunction · 0.95

Calls 7

GetTreeSizeMethod · 0.95
addTreeMethod · 0.95
GetCommitSizeMethod · 0.95
addParentMethod · 0.95
NewCount32Function · 0.92
recordCommitMethod · 0.80
IncrementMethod · 0.45

Tested by

no test coverage detected