Skip to content

Commit 008f2de

Browse files
committed
prrun: be quieter
1 parent 2dca891 commit 008f2de

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

prrun/main.go

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,11 @@ func getPlatformBinaryName(release *GitHubRelease, projectName string) (string,
185185
return "", "", fmt.Errorf("unsupported architecture: %s", archName)
186186
}
187187

188-
// Debug: Show available assets
188+
// Debug: Show available assets only on error
189189
if len(release.Assets) == 0 {
190190
return "", "", fmt.Errorf("release %s has no assets (the build may have failed)", release.TagName)
191191
}
192192

193-
fmt.Printf("Available assets (%d):\n", len(release.Assets))
194-
for _, asset := range release.Assets {
195-
fmt.Printf(" - %s\n", asset.Name)
196-
}
197-
fmt.Println()
198-
199193
// Find the matching asset
200194
// Expected formats:
201195
// 1. project-version-os-arch (e.g., dissect-pr-123.1-linux-amd64)
@@ -213,12 +207,17 @@ func getPlatformBinaryName(release *GitHubRelease, projectName string) (string,
213207
}
214208
}
215209

216-
return "", "", fmt.Errorf("no binary found for %s/%s in release %s (expected name pattern: %s-*-%s-%s or %s--*-%s-%s)", osName, archName, release.TagName, projectName, osName, archName, projectName, osName, archName)
210+
return "", "", fmt.Errorf("no binary found for %s/%s in release %s (expected name pattern: %s-*-%s-%s or %s--*-%s-%s). Available assets: %v", osName, archName, release.TagName, projectName, osName, archName, projectName, osName, archName, func() []string {
211+
var names []string
212+
for _, asset := range release.Assets {
213+
names = append(names, asset.Name)
214+
}
215+
return names
216+
}())
217217
}
218218

219219
// downloadBinary downloads a binary from a URL to a local path
220220
func downloadBinary(downloadURL, destPath string) error {
221-
fmt.Printf("Downloading binary from %s...\n", downloadURL)
222221

223222
req, err := createAuthenticatedRequest("GET", downloadURL)
224223
if err != nil {
@@ -268,7 +267,7 @@ func downloadBinary(downloadURL, destPath string) error {
268267
return fmt.Errorf("failed to make binary executable: %w", err)
269268
}
270269

271-
fmt.Printf("✓ Binary cached at %s\n", destPath)
270+
// Binary successfully cached (no output on success)
272271
return nil
273272
}
274273

@@ -342,24 +341,23 @@ func main() {
342341
projectName = prInfo.Project
343342
}
344343

345-
fmt.Printf("Looking for PR #%d in %s/%s", prInfo.PRNum, prInfo.Owner, prInfo.Repo)
346-
if projectName != "" {
347-
fmt.Printf(" (project: %s)", projectName)
348-
}
349-
fmt.Println()
344+
// Only show debug info on errors, not on success
350345

351346
// Find the PR release
352347
release, err := findPRRelease(prInfo.Owner, prInfo.Repo, prInfo.PRNum, projectName)
353348
if err != nil {
354-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
349+
fmt.Fprintf(os.Stderr, "Looking for PR #%d in %s/%s", prInfo.PRNum, prInfo.Owner, prInfo.Repo)
350+
if projectName != "" {
351+
fmt.Fprintf(os.Stderr, " (project: %s)", projectName)
352+
}
353+
fmt.Fprintf(os.Stderr, "\nError: %v\n", err)
355354
os.Exit(1)
356355
}
357356

358-
fmt.Printf("Found release: %s\n", release.TagName)
359-
360357
// Get the binary name for the current platform
361358
binaryName, downloadURL, err := getPlatformBinaryName(release, projectName)
362359
if err != nil {
360+
fmt.Fprintf(os.Stderr, "Found release: %s\n", release.TagName)
363361
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
364362
os.Exit(1)
365363
}
@@ -381,18 +379,9 @@ func main() {
381379
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
382380
os.Exit(1)
383381
}
384-
} else {
385-
fmt.Printf("✓ Using cached binary at %s\n", cachePath)
386382
}
387383

388-
// Run the binary
389-
fmt.Println()
390-
if len(binaryArgs) > 0 {
391-
fmt.Printf("Running: %s %s\n", binaryName, strings.Join(binaryArgs, " "))
392-
} else {
393-
fmt.Printf("Running: %s\n", binaryName)
394-
}
395-
fmt.Println(strings.Repeat("-", 50))
384+
// Run the binary (no debug output on success)
396385

397386
if err := runBinary(cachePath, binaryArgs); err != nil {
398387
if exitErr, ok := err.(*exec.ExitError); ok {

0 commit comments

Comments
 (0)