Skip to content

Commit

Permalink
wip: working on it slowly
Browse files Browse the repository at this point in the history
  • Loading branch information
elhmn committed Sep 25, 2023
1 parent cc04792 commit 7498baf
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions git-sizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,27 @@ func mainImplementation(ctx context.Context, stdout, stderr io.Writer, args []st
progressMeter = meter.NewProgressMeter(stderr, 100*time.Millisecond)
}

refRoots, err := sizes.CollectReferences(ctx, repo, rg)
if err != nil {
return fmt.Errorf("determining which reference to scan: %w", err)
}

roots := make([]sizes.Root, 0, len(refRoots)+len(flags.Args()))
for _, refRoot := range refRoots {
roots = append(roots, refRoot)
}

for _, arg := range flags.Args() {
oid, err := repo.ResolveObject(arg)
var roots []sizes.Root
// If arguments are provided, use them as explicit roots.
if len(flags.Args()) > 0 {
roots = make([]sizes.Root, 0, len(flags.Args()))
for _, arg := range flags.Args() {
oid, err := repo.ResolveObject(arg)
if err != nil {
return fmt.Errorf("resolving command-line argument %q: %w", arg, err)
}
roots = append(roots, sizes.NewExplicitRoot(arg, oid))
}
} else {
refs, err := sizes.CollectReferences(ctx, repo, rg)
if err != nil {
return fmt.Errorf("resolving command-line argument %q: %w", arg, err)
return fmt.Errorf("determining which reference to scan: %w", err)
}

roots = make([]sizes.Root, 0, len(refs))
for _, ref := range refs {
roots = append(roots, ref)
}
roots = append(roots, sizes.NewExplicitRoot(arg, oid))
}

historySize, err := sizes.ScanRepositoryUsingGraph(
Expand Down

0 comments on commit 7498baf

Please sign in to comment.