Sort git rev-list by time and limit results for related files
Sort the git rev-list by time (descending) and limit the result to max 100
commits in the related files calculation. This limits runtime and favors
recent commits, which are more likely to be relevant.
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/claudetool/differential.go b/claudetool/differential.go
index a365df0..1974174 100644
--- a/claudetool/differential.go
+++ b/claudetool/differential.go
@@ -87,7 +87,6 @@
// Find potentially related files that should also be considered
// TODO: add some caching here, since this depends only on the initial commit and the changed files, not the details of the changes
// TODO: make "related files found" w/o other notes be a non-error response
- // TODO: do some kind of decay--weight recency higher, add a cutoff
relatedFiles, err := r.findRelatedFiles(ctx, changedFiles)
if err != nil {
slog.DebugContext(ctx, "CodeReviewer.Run: failed to find related files", "err", err)
@@ -979,7 +978,7 @@
if len(files) == 0 {
return nil, nil
}
- fileArgs := append([]string{"rev-list", "--all", "--"}, files...)
+ fileArgs := append([]string{"rev-list", "--all", "--date-order", "--max-count=100", "--"}, files...)
cmd := exec.CommandContext(ctx, "git", fileArgs...)
cmd.Dir = r.repoRoot
out, err := cmd.CombinedOutput()