From 61376d23b1fb4bd5ca157e7de8a80164394b269d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:58:40 +0000 Subject: [PATCH 1/2] fix: cross-platform --help and beginner-friendly empty diff messages Issue 1: Override cli.HelpPrinter in cmd/app.go to use a direct fmt.Fprint-based renderer, avoiding any OS-specific pager or man-page lookup that can fail on Windows/PowerShell. Issue 2: Replace vague "no diff content collected" with diff-source-aware messages. For staged diffs (the default), users now see: "No staged changes found. Please stage your files using `git add ` before running a review." Agent-Logs-Url: https://github.com/yankeeDamn/git-lrc/sessions/b7e07e01-34b2-4026-b457-3ebd4b059163 Co-authored-by: yankeeDamn <74879019+yankeeDamn@users.noreply.github.com> --- cmd/app.go | 11 +++++++++++ internal/appcore/review_runtime.go | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/cmd/app.go b/cmd/app.go index 39738bc..61f1347 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -2,10 +2,21 @@ package cmd import ( "fmt" + "io" "github.com/urfave/cli/v2" ) +func init() { + // Override the default HelpPrinter to write directly to the provided + // io.Writer using fmt.Fprint. This avoids any OS-specific pager or + // man-page lookup and ensures --help works identically on Windows, + // macOS, and Linux. + cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { + cli.HelpPrinterCustom(w, templ, data, nil) + } +} + // Handlers contains injected command actions so CLI wiring can live outside main. type Handlers struct { RunReviewSimple cli.ActionFunc diff --git a/internal/appcore/review_runtime.go b/internal/appcore/review_runtime.go index c18ce75..127800c 100644 --- a/internal/appcore/review_runtime.go +++ b/internal/appcore/review_runtime.go @@ -170,7 +170,7 @@ func runReviewWithOptions(opts reviewopts.Options) error { return fmt.Errorf("failed to collect diff for vouch: %w", diffErr) } if len(diffContent) == 0 { - return fmt.Errorf("no diff content to vouch for") + return fmt.Errorf("%s", noDiffMessage(opts.DiffSource)) } parsedFiles, parseErr := parseDiffToFiles(diffContent) if parseErr != nil { @@ -271,7 +271,7 @@ func runReviewWithOptions(opts reviewopts.Options) error { } if len(diffContent) == 0 { - return fmt.Errorf("no diff content collected") + return fmt.Errorf("%s", noDiffMessage(opts.DiffSource)) } var fakeBaseFiles []reviewmodel.DiffReviewFileResult @@ -1368,6 +1368,25 @@ func collectDiffWithOptions(opts reviewopts.Options) ([]byte, error) { } } +// noDiffMessage returns a beginner-friendly error string tailored to the +// diff source that produced no content. +func noDiffMessage(diffSource string) string { + switch diffSource { + case "staged": + return "No staged changes found. Please stage your files using `git add ` before running a review." + case "working": + return "No working-tree changes found. Make some edits before running a review." + case "commit": + return "The specified commit(s) produced an empty diff. Verify the commit reference and try again." + case "range": + return "The specified range produced an empty diff. Verify the range and try again." + case "file": + return "The provided diff file is empty. Provide a non-empty diff file." + default: + return "No diff content collected." + } +} + // runCommitAndMaybePush commits the staged changes and optionally pushes with safety checks. func runCommitAndMaybePush(message string, push bool, verbose bool) error { msg := strings.TrimSpace(message) From f48d880b8be2aef45e9fec634bffb9a5e6261f60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:59:38 +0000 Subject: [PATCH 2/2] fix: add clarifying comment on HelpPrinter override rationale Agent-Logs-Url: https://github.com/yankeeDamn/git-lrc/sessions/b7e07e01-34b2-4026-b457-3ebd4b059163 Co-authored-by: yankeeDamn <74879019+yankeeDamn@users.noreply.github.com> --- cmd/app.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/app.go b/cmd/app.go index 61f1347..c55a8a7 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -12,6 +12,9 @@ func init() { // io.Writer using fmt.Fprint. This avoids any OS-specific pager or // man-page lookup and ensures --help works identically on Windows, // macOS, and Linux. + // HelpPrinterCustom renders the help template directly into w via + // text/template.Execute — no external pager, man-page, or shell command + // is invoked, which is what makes this safe on Windows/PowerShell. cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) { cli.HelpPrinterCustom(w, templ, data, nil) }