MCPcopy
hub / github.com/github/git-sizer / ScanRepositoryUsingGraph

Function ScanRepositoryUsingGraph

sizes/graph.go:65–336  ·  view source on GitHub ↗

ScanRepositoryUsingGraph scans `repo`, using `rg` to decide which references to scan and how to group them. `nameStyle` specifies whether the output should include full names, hashes only, or nothing in the footnotes. `progress` tells whether a progress meter should be displayed while it works. It

(
	repo *git.Repository, rg RefGrouper, nameStyle NameStyle,
	progressMeter meter.Progress,
)

Source from the content-addressed store, hash-verified

63//
64// It returns the size data for the repository.
65func ScanRepositoryUsingGraph(
66 repo *git.Repository, rg RefGrouper, nameStyle NameStyle,
67 progressMeter meter.Progress,
68) (HistorySize, error) {
69 ctx, cancel := context.WithCancel(context.TODO())
70 defer cancel()
71
72 graph := NewGraph(rg, nameStyle)
73
74 refIter, err := repo.NewReferenceIter(ctx)
75 if err != nil {
76 return HistorySize{}, err
77 }
78
79 objIter, err := repo.NewObjectIter(context.TODO())
80 if err != nil {
81 return HistorySize{}, err
82 }
83
84 errChan := make(chan error, 1)
85 var refsSeen []refSeen
86 // Feed the references that we want into the stdin of the object
87 // iterator:
88 go func() {
89 defer objIter.Close()
90
91 errChan <- func() error {
92 for {
93 ref, ok, err := refIter.Next()
94 if err != nil {
95 return err
96 }
97 if !ok {
98 return nil
99 }
100
101 walk, groups := rg.Categorize(ref.Refname)
102
103 refsSeen = append(
104 refsSeen,
105 refSeen{
106 Reference: ref,
107 walked: walk,
108 groups: groups,
109 },
110 )
111
112 if !walk {
113 continue
114 }
115
116 if err := objIter.AddRoot(ref.OID); err != nil {
117 return err
118 }
119 }
120 }()
121 }()
122

Callers 5

mainImplementationFunction · 0.92
TestBombFunction · 0.92
TestTaggedTagsFunction · 0.92
TestFromSubdirFunction · 0.92
TestSubmoduleFunction · 0.92

Calls 15

CloseMethod · 0.95
NextMethod · 0.95
AddRootMethod · 0.95
NextMethod · 0.95
RegisterBlobMethod · 0.95
CloseMethod · 0.95
RequestObjectMethod · 0.95
NextMethod · 0.95
RegisterTreeMethod · 0.95
RegisterCommitMethod · 0.95
RegisterTagMethod · 0.95
RegisterReferenceMethod · 0.95

Tested by 4

TestBombFunction · 0.74
TestTaggedTagsFunction · 0.74
TestFromSubdirFunction · 0.74
TestSubmoduleFunction · 0.74