Skip to content

Commit 6cd74f8

Browse files
committed
fix: SQL dedup by project_slug only + fish standalone flags
Address BugBot round 4 findings: 1. SQL: Changed DISTINCT to GROUP BY project_slug so the same project cached with slightly different names (e.g., after a rename) only appears once, using the most recently cached name. 2. Fish: Added flag completions for standalone commands (e.g., api --method). Previously only grouped subcommands had flag completions.
1 parent 74ac8e6 commit 6cd74f8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/lib/completions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,20 @@ export function generateFishCompletion(binaryName: string): string {
494494
})
495495
.join("\n");
496496

497+
// Flag completions for standalone commands (e.g., `sentry api --method`)
498+
const standaloneFlagLines = standalone
499+
.filter((cmd) => cmd.flags.length > 0)
500+
.map((cmd) => {
501+
const flags = cmd.flags
502+
.map(
503+
(f) =>
504+
`complete -c ${binaryName} -n "__fish_seen_subcommand_from ${cmd.name}" -l "${f.name}" -d "${escapeDblQuote(f.brief)}"`
505+
)
506+
.join("\n");
507+
return `\n# ${cmd.name} flags\n${flags}`;
508+
})
509+
.join("\n");
510+
497511
return `# fish completion for ${binaryName}
498512
# Auto-generated from command definitions
499513
@@ -514,6 +528,7 @@ end
514528
# Top-level commands
515529
${topLevelLines}
516530
${subLines}
531+
${standaloneFlagLines}
517532
518533
# Dynamic completions (org slugs, project names)
519534
complete -c ${binaryName} -n "not __fish_use_subcommand" -a "" -k

src/lib/db/project-cache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ export async function getCachedProjectsForOrg(
149149
orgSlug: string
150150
): Promise<{ projectSlug: string; projectName: string }[]> {
151151
const db = getDatabase();
152+
// Group by project_slug to deduplicate — take the most recently cached name
153+
// in case the same project appears under different cache keys with slightly
154+
// different names (e.g., after a rename between caching events).
152155
const rows = db
153156
.query(
154-
"SELECT DISTINCT project_slug, project_name FROM project_cache WHERE org_slug = ?"
157+
"SELECT project_slug, project_name FROM project_cache WHERE org_slug = ? GROUP BY project_slug ORDER BY cached_at DESC"
155158
)
156159
.all(orgSlug) as Pick<ProjectCacheRow, "project_slug" | "project_name">[];
157160

0 commit comments

Comments
 (0)