fix(cli): suppress no-git-repo note with --quiet flag
The "Note: No git repository initialized" message now respects the --quiet flag, preventing non-essential output in quiet mode. Fixes #1080 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -355,7 +355,9 @@ func startDaemonProcess(socketPath string) bool {
|
||||
// Skip attempting to start and avoid the 5-second wait if not in git repo
|
||||
if !isGitRepo() {
|
||||
debugLog("not in a git repository, skipping daemon start")
|
||||
fmt.Fprintf(os.Stderr, "%s No git repository initialized - running without background sync\n", ui.RenderMuted("Note:"))
|
||||
if !quietFlag {
|
||||
fmt.Fprintf(os.Stderr, "%s No git repository initialized - running without background sync\n", ui.RenderMuted("Note:"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -361,6 +361,41 @@ func TestDaemonAutostart_StartDaemonProcess_NoGitRepo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDaemonAutostart_StartDaemonProcess_NoGitRepo_Quiet(t *testing.T) {
|
||||
// Test that startDaemonProcess suppresses the note when quietFlag is true
|
||||
tmpDir := t.TempDir()
|
||||
oldDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("Getwd: %v", err)
|
||||
}
|
||||
oldQuiet := quietFlag
|
||||
defer func() {
|
||||
_ = os.Chdir(oldDir)
|
||||
quietFlag = oldQuiet
|
||||
}()
|
||||
|
||||
// Change to a temp directory that is NOT a git repo
|
||||
if err := os.Chdir(tmpDir); err != nil {
|
||||
t.Fatalf("Chdir: %v", err)
|
||||
}
|
||||
|
||||
// Enable quiet mode
|
||||
quietFlag = true
|
||||
|
||||
// Capture stderr to verify the message is suppressed
|
||||
output := captureStderr(t, func() {
|
||||
result := startDaemonProcess(filepath.Join(tmpDir, "bd.sock"))
|
||||
if result {
|
||||
t.Errorf("expected startDaemonProcess to return false when not in git repo")
|
||||
}
|
||||
})
|
||||
|
||||
// Verify the message is NOT shown in quiet mode
|
||||
if strings.Contains(output, "No git repository initialized") {
|
||||
t.Errorf("expected no output in quiet mode, got: %q", output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDaemonAutostart_RestartDaemonForVersionMismatch_Stubbed(t *testing.T) {
|
||||
oldExec := execCommandFn
|
||||
oldWait := waitForSocketReadinessFn
|
||||
|
||||
Reference in New Issue
Block a user