GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Still run `git for-each-ref` when explicit roots and reference filter… · github/git-sizer@721e353

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • git-sizer.go
  • git
    • ref_filter.go
  • internal/refopts
    • ref_group.go
    • ref_group_builder.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git-sizer.go‎

Copy file name to clipboardExpand all lines: git-sizer.go
+13-6Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,26 +307,33 @@ func mainImplementation(ctx context.Context, stdout, stderr io.Writer, args []st
307307
}
308308

309309
var roots []sizes.Root
310+
var explicitRoots []sizes.Root
310311
// If arguments are provided, use them as explicit roots.
311312
if len(flags.Args()) > 0 {
312-
roots = make([]sizes.Root, 0, len(flags.Args()))
313+
explicitRoots = make([]sizes.Root, 0, len(flags.Args()))
313314
for _, arg := range flags.Args() {
314315
oid, err := repo.ResolveObject(arg)
315316
if err != nil {
316317
return fmt.Errorf("resolving command-line argument %q: %w", arg, err)
317318
}
318-
roots = append(roots, sizes.NewExplicitRoot(arg, oid))
319+
explicitRoots = append(explicitRoots, sizes.NewExplicitRoot(arg, oid))
319320
}
321+
}
322+
323+
// If no reference filters and no explicit roots were provided
324+
if git.IsNoReferencesFilter(rgb.GetTopLevelGroup().GetFilter()) {
325+
roots = explicitRoots
320326
} else {
321-
refs, err := sizes.CollectReferences(ctx, repo, rg)
327+
refRoots, err := sizes.CollectReferences(ctx, repo, rg)
322328
if err != nil {
323329
return fmt.Errorf("determining which reference to scan: %w", err)
324330
}
325331

326-
roots = make([]sizes.Root, 0, len(refs))
327-
for _, ref := range refs {
328-
roots = append(roots, ref)
332+
roots = make([]sizes.Root, 0, len(refRoots)+len(explicitRoots))
333+
for _, refRoot := range refRoots {
334+
roots = append(roots, refRoot)
329335
}
336+
roots = append(roots, explicitRoots...)
330337
}
331338

332339
historySize, err := sizes.ScanRepositoryUsingGraph(
Collapse file

‎git/ref_filter.go‎

Copy file name to clipboardExpand all lines: git/ref_filter.go
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,8 @@ type regexpFilter struct {
140140
func (f regexpFilter) Filter(refname string) bool {
141141
return f.re.MatchString(refname)
142142
}
143+
144+
func IsNoReferencesFilter(val interface{}) bool {
145+
_, ok := val.(noReferencesFilter)
146+
return ok
147+
}
Collapse file

‎internal/refopts/ref_group.go‎

Copy file name to clipboardExpand all lines: internal/refopts/ref_group.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ type refGroup struct {
3030
otherRefGroup *sizes.RefGroup
3131
}
3232

33+
func (rg *refGroup) GetFilter() git.ReferenceFilter {
34+
return rg.filter
35+
}
36+
3337
func (rg *refGroup) collectSymbols(refname string) (bool, []sizes.RefGroupSymbol) {
3438
walk := false
3539
var symbols []sizes.RefGroupSymbol
Collapse file

‎internal/refopts/ref_group_builder.go‎

Copy file name to clipboardExpand all lines: internal/refopts/ref_group_builder.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type RefGroupBuilder struct {
2222
groups map[sizes.RefGroupSymbol]*refGroup
2323
}
2424

25+
func (rgb *RefGroupBuilder) GetTopLevelGroup() *refGroup {
26+
return rgb.topLevelGroup
27+
}
28+
2529
// NewRefGroupBuilder creates and returns a `RefGroupBuilder`
2630
// instance.
2731
func NewRefGroupBuilder(configger Configger) (*RefGroupBuilder, error) {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.