feat: add --commit flag to issues list command #267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
deepsource issues listcurrently only shows issues from the repository's default branch. This PR adds a--commitflag that queries issues from the analysis run for a specific commit SHA, enabling users to see issues found on PR branches and non-default branches.Motivation: When using DeepSource in CI pipelines or local pre-push hooks, it's useful to check what issues a specific commit introduced — particularly on feature branches where DeepSource already runs analysis via the GitHub App. Today the only way to see branch-specific results is through the web dashboard; this change brings that capability to the CLI.
NOTE: This PR is AI-written but seems to work. I don't know Go, otherwise I'd scrutinize myself. Please LMK if changes need to be made.
Usage
Changes
New file:
deepsource/issues/queries/list_run_issues.gorun(commitOid:)→checks→occurrencesto fetch issues from a specific analysis runDo()method following the existing patterns inlist_issues.goandlist_file_issues.go--limit(the GraphQL limit applies per-analyzer check, so without the cap, 3 analyzers × 100 limit = 300 results)Modified:
deepsource/client.goGetIssuesByCommit(ctx, commitOID, limit)SDK method, mirroring the existingGetIssuesandGetIssuesForFileModified:
command/issues/list/list.go--commitflag (long form only — no shorthand to avoid-cconflicts with common--configconventions)--repo(commit lookup is repo-agnostic via the API)ResolveRemotewhen--commitis specified (no git context needed)--analyzer,--limit,--json/--csv/--sarif, and--output-fileflags all work with--commitTesting
go build ./...passesgo test ./command/issues/list/passes (existing tests unaffected)run(commitOid:)GraphQL endpoint returns correct data via the DeepSource Cloud API (api.deepsource.io/graphql/)Notes
run(commitOid:)root query field and traverseschecks.occurrencesto collect issues. This field is documented in the DeepSource API but was not previously exposed by the CLI.[]issues.Issueslice used by the default code path.