Skip to content

Commit 897baa1

Browse files
committed
RefRoot: add some methods
We want to add another type of root, so start the virtualization process.
1 parent 757866b commit 897baa1

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

sizes/graph.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func ScanRepositoryUsingGraph(
3838

3939
errChan <- func() error {
4040
for _, refRoot := range refRoots {
41-
if !refRoot.Walk {
41+
if !refRoot.Walk() {
4242
continue
4343
}
4444

45-
if err := objIter.AddRoot(refRoot.OID); err != nil {
45+
if err := objIter.AddRoot(refRoot.OID()); err != nil {
4646
return err
4747
}
4848
}
@@ -258,7 +258,7 @@ func ScanRepositoryUsingGraph(
258258
progressMeter.Start("Processing references: %d")
259259
for _, refRoot := range refRoots {
260260
progressMeter.Inc()
261-
graph.RegisterReference(refRoot.Reference, refRoot.Walk, refRoot.Groups)
261+
graph.RegisterReference(refRoot.Reference(), refRoot.Walk(), refRoot.Groups())
262262
}
263263
progressMeter.Done()
264264

sizes/grouper.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ type RefGrouper interface {
4545
}
4646

4747
type RefRoot struct {
48-
git.Reference
49-
Walk bool
50-
Groups []RefGroupSymbol
48+
ref git.Reference
49+
walk bool
50+
groups []RefGroupSymbol
5151
}
5252

53+
func (rr RefRoot) OID() git.OID { return rr.ref.OID }
54+
func (rr RefRoot) Reference() git.Reference { return rr.ref }
55+
func (rr RefRoot) Walk() bool { return rr.walk }
56+
func (rr RefRoot) Groups() []RefGroupSymbol { return rr.groups }
57+
5358
func CollectReferences(
5459
ctx context.Context, repo *git.Repository, rg RefGrouper,
5560
) ([]RefRoot, error) {
@@ -73,9 +78,9 @@ func CollectReferences(
7378
refsSeen = append(
7479
refsSeen,
7580
RefRoot{
76-
Reference: ref,
77-
Walk: walk,
78-
Groups: groups,
81+
ref: ref,
82+
walk: walk,
83+
groups: groups,
7984
},
8085
)
8186
}

0 commit comments

Comments
 (0)