Repository navigation
Add --exclude-bots filtering - #211
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an --exclude-bots flag to filter out dependency changes authored by common bot accounts across multiple commands, using both SQL-level filtering (for DB-backed queries) and commit-walk logic for commit-to-commit diffs.
Changes:
- Add
--exclude-botsflags tolog,history,stats,blame, and commit-to-commitdiff, plus README usage examples. - Implement bot author detection and SQL query filtering in the database layer; thread new
ExcludeBotsoptions through command handlers. - Add CLI integration tests covering bot exclusion behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents --exclude-bots usage for affected commands. |
| internal/database/queries.go | Adds bot detection + SQL filters; plumbs ExcludeBots through query options; updates GetBlame signature. |
| internal/database/benchmark_test.go | Updates benchmark to new GetBlame options struct signature. |
| cmd/vulns.go | Adapts to GetBlame signature change via BlameOptions. |
| cmd/stats.go | Adds --exclude-bots flag and passes it into StatsOptions. |
| cmd/query_test.go | Adds end-to-end test coverage for --exclude-bots across commands. |
| cmd/log.go | Adds --exclude-bots flag and passes it into LogOptions. |
| cmd/init_test.go | Adds setGitUser helper to create bot vs human commits in tests. |
| cmd/history.go | Adds --exclude-bots flag and passes it into HistoryOptions. |
| cmd/diff.go | Adds --exclude-bots support for commit-to-commit diffs by replaying only non-bot commits. |
| cmd/blame.go | Adds --exclude-bots flag and passes it into BlameOptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrew
left a comment
There was a problem hiding this comment.
The log, history, stats and blame parts look good. Adding ExcludeBots to the option structs and filtering in SQL via appendExcludeBotsFilter is the right approach, and there are no schema changes.
I'd like the diff support dropped from this PR though. depsAfterNonBotCommits calls repo.GetDependencies on both the parent and the commit for every non-bot commit in the range, then replays each diff onto a working set. On a branch that's a few hundred commits ahead of main that's close to a thousand full manifest parses for one git pkgs diff main..feature --exclude-bots. It also shells out to git log via exec.Command where the rest of the codebase uses go-git for history walking.
I did list diff in #17 but having seen what it takes I don't think it's worth the cost. The semantics are also fuzzy: a human commit that touches a line a bot added still carries the bot's change forward, so the reconstructed tree isn't really "what the deps would be without bots". The other four commands cover the use case I actually had in mind, which is filtering authored changes out of reports.
So: drop commitsInRange, depsAfterNonBotCommits, applyDiffToDeps and the diff flag, keep everything else, and I think this is ready.
One small thing on the SQL: LOWER(COALESCE(c.author_name, '')) LIKE ? repeated eight times won't use an index, but log/history/stats already scan by branch so it's not a regression. Fine to leave.
i dropped the diff support from this PR as requested: removed the --exclude-bots flag from diff, deleted commitsInRange, depsAfterNonBotCommits, applyDiffToDeps and the related replay helpers and removed the diff-specific docs/tests... the log/history/stats/blame SQL-backed filtering is unchanged. Tests pass with go test ./cmd, go test ./internal/database, go test ./..., and git diff --check... |
andrew
left a comment
There was a problem hiding this comment.
Thanks, the diff replay path is gone which is what I was after.
Two small things left:
IsBotAuthorininternal/database/queries.gois now unused (it was only called from the removed diff code). Please drop it.- The PR description still lists
diffand the working-tree caveat; can you trim that to match.
Also CI didn't run on 2ae89d1 for some reason, so the next push should pick that up. I'll approve once it's green.
|
Correction on the CI note above: the run was waiting on maintainer approval for fork workflows, not anything on your end. I've approved it now so it should be running. |
|
ohh, missed it... i removed the unused |
andrew
left a comment
There was a problem hiding this comment.
Both followups landed. The four SQL-backed commands are the right scope and appendExcludeBotsFilter plugs in cleanly. Thanks.
Closes #17
Summary
Adds
--exclude-botssupport for commands that show dependency changes by author:loghistorystatsblameBot authors are matched case-insensitively by name or email using:
[bot]dependabotrenovategreenkeeperTests
go build ./...go test ./...go test -race ./...go tool golangci-lint run ./...git diff --check